43
4.4.6 CONVERTING FOR STRINGS
Several commands are available for converting strings to uppercase or lowercase letters,
as well as converting strings to numbers, and vice versa.
ASC
Purpose
To return the decimal value for the ASCII code for the first character of a given
string.
Syntax A% = ASC(X$)
Remarks “A%” is an integer variable to be assigned to the result.
“X$” is a string variable, consisting of characters.
Example
CHR$
Purpose To return the character for a given ASCII value.
Syntax A$ = CHR$(N%)
Remarks “A$” is a string variable to be assigned to the result.
“N%” is a numeric expression in the range of 0 to 255.
Example
HEX$
Purpose
To return a string that represents the hexadecimal value (base 16) of the
decimal argument.
Syntax A$ = HEX$(N%)
Remarks “A$” is a string variable to be assigned to the result.
“N%”
is a numeric expression in the range of 0 to 2,147,483,647; it is rounded
to an integer before HEX$(N%) is evaluated.
Example
A$ = HEX$(140) ‘ A$ = “8C”
LCASE$
Purpose To return a copy of a string in which all uppercase letter
lowercase letters.
Syntax A$ = LCASE$(X$)
Remarks “A$” is a string variable to be assigned to the result.
“X$” may be a string variable, string expression, or string constant.
Example
String1$ = “John Thomas”
String2$ = LCASE$(String1$)
‘ String2$ = “john Thomas”