Returns a string containing a specified number of characters from the left side of a string.
Public Shared Function Left( _ ByVal Str As String, _ ByVal Length As Integer _ ) As String
Exception type | Error number | Condition |
---|---|---|
5 | Length < 0. |
To determine the number of characters in Str, use the Len function. If used in a Windows Form, or any other class that has a Left property, you must fully qualify the function with Microsoft.VisualBasic.Left
.
This example demonstrates the use of the Left function to return a substring of a given String. In a class that has a Left property, it may be necessary to fully qualify the Left function.
Dim myString As String = "Hello World!" Dim subString As String subString = Microsoft.VisualBasic.Left(myString, 5) ' Returns "Hello"
Right Function | Len Function | Mid Function |