VBS tutorial: function – left function


Left function

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

Left(string, length)



String expression whose leftmost character is returned. IfstringIf the parameter contains null, theNull


A numeric expression indicating the number of characters to return. If it is 0, return a zero length string (“”); If greater than or equal tostringParameter, the entire string is returned.


AvailableLenFunction determinationstringThe number of characters in the parameter.

The following example usesLeftThe function returns the left three letters of mystring:

Dim mystring, leftstringmystring = "vbscipt" leftstring = left (mystring, 3) 'leftstring contains "VBS".

be careful    LeftBFunction is used with byte data contained in a string.lengthInstead of specifying the number of strings to return, you specify the number of bytes.