Using String searching methods: IndexOf : String Search « Data Types « VB.Net






Using String searching methods: IndexOf

Using String searching methods: IndexOf
   
Imports System

Public Class MainClass

   Shared Sub Main()
      Dim letters As String = "abcdefghijklmabcdefghijklm"
      Dim searchLetters As Char() = New Char() {"c"c, "a"c, "$"c}

      Console.WriteLine(" test IndexOf to locate a character in a string")
      Console.WriteLine("""c"" is located at index " & _
         letters.IndexOf("c"c) )

      Console.WriteLine("""a"" is located at index " & _
         letters.IndexOf("a"c, 1) )

      Console.WriteLine("""$"" is located at index " & _
         letters.IndexOf("$"c, 3, 5) )


   End Sub ' Main

End Class


           
         
    
    
  








Related examples in the same category

1.Combine Insert and IndexOfCombine Insert and IndexOf
2.LastIndexOf to find a character in a stringLastIndexOf to find a character in a string
3.IndexOf to locate a substring in a stringIndexOf to locate a substring in a string
4.LastIndexOf to find a substring in a stringLastIndexOf to find a substring in a string
5.IndexOfAny to find first occurrence of character in arrayIndexOfAny to find first occurrence of character in array
6.LastIndexOfAny to find first occurrence of character in arrayLastIndexOfAny to find first occurrence of character in array
7.String IndexOf and InsertString IndexOf and Insert
8.String: Substring, LastIndexOfString: Substring, LastIndexOf
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[])