ASC function

Purpose | Returns the character code of the character at the specified position in a string.
Syntax | CharCode& = ASC(StrgExpr [, position&])

Remarks

ASC returns the character code of a particular character in the string expression. If the string is an ANSI string, the returned value will be in the range of 0 to 255. If it is a Unicode string, the returned value will be in the range of 0 to 65535.

The optional position& parameter determines which character is to be checked. The first character is one, the second two, etc. If the position& parameter is missing, the first character is presumed. If position& is negative, ASC counts from the end of the string in reverse. That is, -1 specifies the last character, -2 specifies the second to last character, etc.

CHR$ is the natural complement of ASC. It produces a one-character string corresponding to its ASCII or Unicode argument.

Restrictions | If the string passed is null (zero-length) or the position is zero or greater than the length of the string, the value -1 is returned.
See also | ASC statement, CHR$
Example | x$ = "The ASCII value of A is" + STR$( ASC("A") )
Result | The ASCII value of A is 65