Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

SubString

Option Strict On  Imports System  Class Tester      Public Shared Sub Main( )          Dim s1 As String = "One Two Three Four"          Dim index As Integer          index = s1.LastIndexOf(" ")          Dim s2 As String = s1.Substring((index + 1))          s1 = s1.Substring(0, index)          index = s1.LastIndexOf(" ")          Dim s3 As String = s1.Substring((index + 1))          s1 = s1.Substring(0, index)          index = s1.LastIndexOf(" ")          Dim s4 As String = s1.Substring((index + 1))          s1 = s1.Substring(0, index)          index = s1.LastIndexOf(" ")          Dim s5 As String = s1.Substring((index + 1))          Console.WriteLine("s1: {0}", s1)          Console.WriteLine("s2: {0}", s2)          Console.WriteLine("s3: {0}", s3)          Console.WriteLine("s4: {0}", s4)          Console.WriteLine("s5: {0}", s5)      End Sub 'Main  End Class 'Tester s1: One s2: Four s3: Three s4: Two s5: One