IndexOf to locate a substring in a string
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("IndexOf to locate a substring in a string")
Console.WriteLine("""def"" is located at" & _
" index " & letters.IndexOf("def"))
Console.WriteLine("""def"" is located at index " & _
letters.IndexOf("def", 7))
Console.WriteLine("""hello"" is located at index " & _
letters.IndexOf("hello", 5, 15))
End Sub ' Main
End Class
Related examples in the same category