Asc Function
Returns the ASCII code of the first character in a character string. (Returns the character code in a decimal number.)
Syntax
Asc(string)
Parameters
- string
- Specify a string of one or more characters, either as a string expression or as a direct string.
Return Values
Returns an integer representing the ASCII code of the first character in the string sent to the Asc function.
Description
The Asc function is used to convert a character to its ASCII numeric representation. The character string send to the ASC function may be a constant or a variable.
Note
Only the First Character ASCII Value is Returned
Although the Asc instruction allows character strings larger than 1 character in length, only the 1st character is actually used by the Asc instruction. Asc returns the ASCII value of the 1st character only.
See Also
Chr$, InStr, Left$, Len, Mid$, Right$, Space$, Str$, Val
Asc Function Example
This example uses the Asc instruction in a program and from the command window as follows:
Function asctest
Integer a, b, c
a = Asc("a")
b = Asc("b")
c = Asc("c")
Print "The ASCII value of a is ", a
Print "The ASCII value of b is ", b
Print "The ASCII value of c is ", c
Fend
From the command window:
>print asc("a")
97
>print asc("b")
98
>