Left Function

Returns a specified number of characters from the left side of a string.

Syntax

Left(string, length)

Arguments:

  • String: String expression from which the leftmost characters are returned.
  • Length: Numeric expression indicating how many characters to return. If 0, a zero-length string(" ") is returned. If greater than or equal to the number of characters in string, the entire string is returned.

Remarks

To determine the number of characters in string, use the Len function.

The following example uses the Left function to return the first three characters of MyString:

Example 1:

Dim MyString, LeftString
MyString = "BSL"
LeftString = Left(MyString, 3) 
' Output: "BSL".

Example 2:

Dim MyString, LeftString
MyString = "HelloWorld"
LeftString = Left(MyString, 5) 
' Output: "Hello"

Example 3:

Dim MyString, LeftString
MyString = "HelloWorld"
LeftString = Left(MyString, 0)  
' Output:  ("")

Example 4:

Dim MyString, LeftString
MyString = "Hello"
LeftString = Left(MyString, 10)  
' Output: "Hello"

Example 5:

Dim MyString, LeftString
MyString = Null
LeftString = Left(MyString, 3)  
'Output: Null