Syntax
Left$(Source$, Count)
Remarks
Returns the leftmost Count characters of Source$.
Examples
This example displays the text "Legal" in the status bar:
a$ = "Legal File List" Print Left$(a$, 5)
The following example uses Left$() to return the first part of a hyphenated word. InStr() is used to determine the position of the hyphen (-) character. Left$() is then used to return all the characters to the left of the hyphen.
wholeWord$ = "fade-out" hyphen = InStr(wholeWord$, "-") firstWord$ = Left$(wholeWord$, (hyphen - 1)) MsgBox "First part of word: " + firstWord$
A similar set of instructions can be used to return the characters before the filename extension in an MS-DOS filename. Instead of determining the position of the hyphen, you would use InStr() to return the position of the period (.) character. This can be useful if you want to save a copy of the active document with a different filename extension. For an example, see InStr().
See Also
InStr(), Len(), LTrim$(), Mid$(), Right$(), RTrim$()