Visual Basic Substring Method
In Visual Basic, the Substring method is used to get a desired part from a string.
It has 2 ways of use.
In its first use, the starting index is given and the number of characters to be taken from here is specified.
Module ModuleTest
Sub Main()
Dim substr As String = "test string"
Dim res As String = substr.Substring(0, 3)
Console.WriteLine(res)
Console.ReadLine()
End Sub
End Module The result here is "tes".
In the second use, only the starting index is given. All characters after the specified value are taken.
Module ModuleTest
Sub Main()
Dim substr As String = "test string"
Dim res As String = substr.Substring(3)
Console.WriteLine(res)
Console.ReadLine()
End Sub
End Module The result here is "t string".