Mega Code Archive

 
Categories / VB.Net / Data Types
 

LastIndexOf to find 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("LastIndexOf to find a substring in a string")       Console.WriteLine("Last ""def"" is located " & _          "at index " & letters.LastIndexOf("def"))       Console.WriteLine("Last ""def"" is located at " & _          letters.LastIndexOf("def", 25))       Console.WriteLine("Last ""hello"" is located at " & _         "index " & letters.LastIndexOf("hello", 20, 15))    End Sub ' Main End Class