Get Left String Method
The Get Left String method returns a string copied from the beginning of another string. If the value in the length argument is greater than the length of the string that the string argument specifies, then it returns the entire string.
Format
Left[$](string, length)
For information about the dollar sign, see Usage of the Dollar Sign.
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
string |
A string or an expression that contains a string. This method returns a substring of the string that you specify. The substring begins at the first character of this string. If this argument contains a NULL value, then this method returns a Null variant. For more information, see Variants. This method accepts any type of string, including numeric values, and converts the input value to a string. |
length |
An integer that specifies the number of characters to copy. |
Example
The following example gets a user first name from the entire name:
Sub Button_Click
Dim username as String
Dim count as Integer
Dim firstname as String
Dim charspace
charspace = Chr(32)
username = "Chris Smith"
count = InStr(username,charspace)
firstname = Left(username,count)
End Sub