Returns the ANSI character code corresponding to the first letter in a string.
Asc(string)
string
Any valid string expression. If the string contains no characters, a run-time error occurs.
The AscB function is used with byte data contained in a string. Instead of returning the character code for the first character, AscB returns the first byte. AscW is provided for 32-bit platforms that use Unicode characters. It returns the Unicode (wide) character code, thereby avoiding the conversion from Unicode to ANSI.
In the following example, Asc returns the ANSI character code of the first letter of each string:
Dim MyNumber
MyNumber = Asc("A") ' Returns 65.
MyNumber = Asc("a") ' Returns 97.
MyNumber = Asc("Apple") ' Returns 65.
Copyright 2001 Sun Microsystems, Inc. All rights reserved. Legal Notice.