From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Asc (the global function) is here for compatibility with Visual Basic. You should instead use String.Asc.

Returns the integer code point for the first character in the string using the character's encoding.


result = stringVariable.Asc

Part Type Description
result Integer The ASCII value of the first character of string.
StringVariable String Any variable of type String.


The Asc function returns the code point for the first character in the passed String in the characters encoding. Characters 0 through 127 are the standard ASCII set, which are the same on practically every encoding.

If you need to get the ASCII code of the first byte of the string rather than the first character, use the String.AscByte function.


This example uses the Asc function to get the ASCII value of a character.

Var result As Integer
Var source As String = "A"
result = source.Asc // returns 65

This example gets the code point for the "≥" symbol

Var source As String = "≥"
Var result As Integer
result = source.Asc

See Also

String for a complete list of functions; TextEncoding class.