Q(uick)BASIC Function: LEFT$
Quick View
LEFT$
A string processing function that returns a string consisting of the leftmost n characters of a string
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- LEFT$(stringexpression$,n%)
- RIGHT$(stringexpression$,n%)
Description/Parameter(s)
stringexpression$ | Any string expression. |
n% | The number of characters to return, beginning with the leftmost or rightmost string character. |
Example
a$ = "Microsoft QBasic"
PRINT LEFT$(a$, 5) 'Output is: Micro
PRINT RIGHT$(a$, 5) 'Output is: Basic
See also:
Syntax
- LEFT$(stringexpression,n)
Description/Parameter(s)
The argument stringexpression can be any string variable, string constant, or string expression.
The argument n is a numeric expression in the range 0-32,767 indicating how many characters are to be returned.
If n is greater than the number of characters in stringexpression, the entire string is returned. To find the number of characters in stringexpression, use LEN(stringexpression).
If n is zero, the null string (length zero) is returned.
Example
This example prints the leftmost five characters of A$.
CLS ' Clear screen
A$="BASIC LANGUAGE"
B$=LEFT$(A$, 5)
PRINT B$
Sample Output:
BASICSee also:
Syntax
- LEFT$(stringexpression$,n%)
Description/Parameter(s)
- If n% is 0, the null string (a zero-length string) is returned.
- If n% is greater than or equal to the number of characters in stringexpression$, the entire string is returned.
- To find the number of characters in stringexpression$, use LEN(stringexpression$).
Example
This example uses the LEFT$ function to print the leftmost five characters of a string.
CLS 'Clear screen.
A$ = "BASIC LANGUAGE"
B$ = LEFT$(A$, 5)
PRINT B$
Sample Output:
BASICSee also: