In VB, the Asc
functions return the numeric code of a character.
Syntax
Asc (strExpression)
AscB (strExpression)
AscW (strExpression)
Where the strExpression
argument is a string for which you want to return the numeric code of the first character.
Example
Dim intAnsi as Integer
intAnsi = Asc("Hello")
Output
The above example places the value 72
(the ANSI code for the character H) in the variable intAnsi
.
Asc
The Asc
function returns the numeric ANSI value of the first character in the supplied string. The range of returns is 0 to 255 on the non-DBCS systems and -32768 to 32767 on DBCS systems.
AscB
The AscB
function in VB is used with byte strings. Instead of returning the character code for the first character, AscB
returns the first byte.
AscW
The AscW
function returns the Unicode character code, except on platforms where Unicode is not supported; in those cases, the behavior of AscW
is identical to the Asc function.