16.9. Miscellaneous String Methods

Class String provides several methods that return modified copies of Strings. Figure 16.8 demonstrates String methods Replace, ToLower, ToUpper and Trim. None of these methods modifies the original String.

Figure 16.8. String methods Replace, ToLower, ToUpper and Trim.
					1
					' Fig. 16.8: StringMethods2.vb
					2
					' Demonstrating String methods Replace, ToLower, ToUpper, Trim,
					3
					' and ToString.
					4
					5
					Module StringMethods2
 6
					Sub Main()
 7
					Dim string1 As String = "cheers!"
					8
					Dim string2 As String = "GOOD BYE "
					9
					Dim string3 As String = " spaces "
					10
					11        Console.WriteLine("string1 = """ & string1 & """" & vbCrLf & _
12
					"string2 = """ & string2 & """" & vbCrLf & _
13
					"string3 = """ & string3 & """")
14
					15
					' call method Replace ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.