String: Substring, LastIndexOf : String Search « Data Types « VB.Net






String: Substring, LastIndexOf

String: Substring, LastIndexOf
   
Imports System
Imports System.Collections
 
Public Class MainClass

    Shared Sub Main(ByVal args As String())
             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

End Class

           
         
    
    
  








Related examples in the same category

1.Combine Insert and IndexOfCombine Insert and IndexOf
2.Using String searching methods: IndexOfUsing String searching methods: IndexOf
3.LastIndexOf to find a character in a stringLastIndexOf to find a character in a string
4.IndexOf to locate a substring in a stringIndexOf to locate a substring in a string
5.LastIndexOf to find a substring in a stringLastIndexOf to find a substring in a string
6.IndexOfAny to find first occurrence of character in arrayIndexOfAny to find first occurrence of character in array
7.LastIndexOfAny to find first occurrence of character in arrayLastIndexOfAny to find first occurrence of character in array
8.String IndexOf and InsertString IndexOf and Insert
9.String IndexOf and Insert at a positionString IndexOf and Insert at a position
10.Sample for String.LastIndexOfAny(Char[])
11.Search string with IndexOf
12.String.LastIndexOfAny Method (Char[])