Visual Basic String Using StartsWith

In Visual Basic, we use the StartsWith() method to determine whether a string starts with the specified character(s). This method, which returns a bool value, has 3 different uses.

The most commonly used form is given in the example below..

Module ModuleTest Sub Main() Dim str As String = "El" Dim name As String() = New String() {"Elif", "Ahmed", "Ela", "Joe", "Mick", "Ali", "Elvin"} For Each i As String In name If i.StartsWith(str) Then Console.WriteLine(i) End If Next Console.ReadLine() End Sub End Module

We tried to understand whether the elements in our name array start with El. We scanned all the elements with the "Foreach" loop and used the "StartsWith()" method. We printed the results true to the screen.



You May Interest

Visual Basic Substring Method

Visual Basic How To Find The Average Of 10 Numbers Using A While ...

Visual Basic Getting Last Character of String

Visual Basic Non-Restart Check If Application is Open

How to Find the Name of the Operating System in Visual Basic ?