Returns the first characters of a string expression.
Left[$](a$ [,m [,fillchar]])
a$ | : sexp |
m | : integer expression |
fillchar | : iexp or sexp |
Left$(a$, m) returns the first m characters of the string expression a$. If m is not given, the first character of a$ is returned. When m < 0 the string a$ is returned completely.
When m is greater than the number of characters in a$ (spaces and Chr$(0) are characters too!), the entire string is returned. When Left() takes a third parameter fillchar, it should specify the character to fill the excess characters of the return value when the source string does not hold enough characters. The fillchar might be ASCII value or a string containing the character to fill the string with.
Print Left$("Hello GFA", 5) // prints Hello
Print Left$("Hello GFA", 20) // prints Hello GFA
Print Left$("Hello GFA", -1) // prints Hello GFA
Print Left$("Hello GFA", 16, ".") // prints Hello GFA.......
Without the optional $ character the function still returns a String data type and not a Variant.
LeftUntil, RightUntil, String, Right(), Mid(), SubStr(), Mid
{Created by Sjouke Hamstra; Last updated: 18/12/2022 by James Gaite}