Name
Left, LeftB Functions
Syntax
Left(string,length)
-
string Use: Required
Data Subtype: String
The string to be processed.
-
length Use: Required
Data Subtype: Long
The number of characters to return from the left of the string.
Return Value
Left and LeftB return a
variant of subtype String.
Description
Returns a string containing the leftmost
length characters of
string.
Rules at a Glance
If
lengthis 0, a zero-length string (“”) is returned.If
lengthis greater than the length ofstring,stringis returned.If
lengthis less than orNull, the function generates runtime error 5, “Invalid procedure call or argument,” and runtime error 94, “Invalid use of Null,” respectively.If
stringcontainsNull,LeftreturnsNull.Leftprocesses strings of characters;LeftBis used to process binary data.
Programming Tips & Gotchas
Use the
Lenfunction to determine the overall length ofstring.When you use the
LeftBfunction with byte data,lengthspecifies the number of bytes to return.
VBScript/VB & VBA Differences
There are no Left$ or
LeftB$ functions available in VBScript.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access