VBS tutorial: function – left function

Time:2021-10-21

Left function

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

Left(string, length)

parameter

string

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

Length

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.

explain

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.