Left$ Function

Returns a substring from the left side of a string expression.

Syntax
Left$(string, count)

Parameters

string
String expression from which the leftmost characters are copied.
count
Specify the number of characters to be copied from the left of the string directly as a numeric value.

Return Values
Returns a string of the leftmost number characters from the character string specified by the user.

Description
Left$ returns the leftmost number characters of a string specified by the user. Left$ can return up to as many characters as are in the character string.

See Also
Asc, Chr$, InStr, Len, Mid$, Right$, Space$, Str$, Val

Left$ Function Example
The example shown below shows a program which takes a part data string as its input and parses out the part number, part name, and part count.

Function ParsePartData(DataIn$ As String, ByRef PartNum$ As String, ByRef PartName$ As String, ByRef PartCount As Integer)

    Integer pos
    String temp$

    pos = Instr(DataIn$, ",")
    PartNum$ = Left$(DataIn$, pos - 1)

    DataIn$ = Right$(datain$, Len(DataIn$) - pos)
    pos = Instr(DataIn$, ",")

    PartName$ = Left$(DataIn$, pos - 1)

    PartCount = Val(Right$(datain$, Len(DataIn$) - pos))

Fend

Some other example results from the Left$ instruction from the Command window.

> Print Left$("ABCDEFG", 2)
 AB

> Print Left$("ABC", 3)
 ABC