Home > Language Reference > String Management Functions > Left$

Left$

The Left$ function returns a string containing the specified number of characters from the left side of a string.

Usage

Used to extract the left part of a string.  

Syntax

var$=Left$(<source_string>, <length>)

Parameters

<source_string>, string from which the leftmost characters have to be returned.

<length>, integer, number of characters to return. 

Return value

var$, string, result of the extraction. If <length> is negative or 0, the function returns an empty string (an empty string is "").

See also

Asc
Chr$
Encrypt
ExtractBetween$
InStr
InStrRev
LCase$
Len
LTrim$
Mid$
Replace$
Right$
RTrim$
SplitIntoArray
Str$
Trim$
UCase$
Val

Examples

a$ = Left$("toto",2) ' Returns "to" in a$

a$ = Left$("toto",0) ' Returns "" in a$

b$ = Left$(a$,2) ' Returns the first 2 characters of a$ and puts them in b$

b$ = Left$(a$,i) ' Returns the first i characters of a$ and puts them in b$