CitectVBA Programming Reference > CitectVBA Function Reference > String Functions > Left, Left$

Left, Left$

Returns the left most Num characters of Str.

The required Str argument is a String expression from which the leftmost characters are returned. If Str contains Null, Null is returned.

The required Num argument is a Variant (Long) numeric expression indicating how many characters to return. If 0, a zero-length string (" ") is returned. If greater than or equal to the number of characters in string, the entire string is returned.

Syntax

Left(Str, Num)

Str:

A string or expression that can represent a valid text value.

Num:

An Integer or expression representing a valid numeric value.

Return Value

The Left function returns a variant containing a String data type. The Left$ function returns a String.

Related Functions

InStr| Mid| Right

Example

Dim strGreeting as String
Dim strTest
strGreeting = "Hello World"
strTest = Left(strGreeting, 1) ' Returns "H".
strTest = Left(strGreeting, 7) ' Returns "Hello W".
strTest = Left(strGreeting, 20) ' Returns "Hello World".