Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

Demonstrating StartsWith and EndsWith methods

Module Tester    Sub Main()       Dim strings As String()       Dim output As String = ""       Dim i As Integer       Dim quotes As Char = ChrW(34)       strings = New String() {"started", "starting", _          "ended", "ending"}       For i = 0 To strings.GetUpperBound(0)          If strings(i).StartsWith("st") Then             Console.WriteLine(" starts with st")          End If       Next       For i = 0 To strings.GetUpperBound(0)          If strings(i).EndsWith("ed") Then             Console.WriteLine(" ends with ed" )          End If       Next    End Sub ' Main End Module starts with st starts with st ends with ed