Dr. Abraham Professor UTPA Chapter 17 Strings Dr. Abraham Professor UTPA
Topics Array of characters String Class StringBuilder Class
Array of Characters Dim characterArray() As Char = New Char(20) {} characterArray = "This is a test" MessageBox.Show(characterArray & Len(characterArray), "Show Character Array")
Showing Each Character MessageBox.Show("Fifth Character is: " & vbCrLf & characterArray(5), "Fifth Character")
Copying Character Array to String Dim myString As String myString = characterArray MessageBox.Show(myString & Len(myString), "Show String") If myString = characterArray Then MessageBox.Show("Compared both and they are equal", "String comparison")
String Class methods Startswith EndsWith For i = 0 To numStrings If myStrings(i).StartsWith((txtStarts.Text)) Then textBoxOutput += myStrings(i) & vbCrLf End If Next EndsWith Similar
String Class methods Locating Characters and Substrings ToUpper yourString.IndexOf(“LookingFor”,whereTobegin) Will yield index of character where it was found ToUpper ToLower Trim
Class StringBuilder It is found in system.text Mostly used to place data in tabular form. See the example from the program.