Asc Function (BASIC)

Returns the ASCII (American Standard Code for Information Interchange) value of the first character in a string expression.


Asc(string) As Long

Return value:



string: Any valid string expression. Only the first character in the string is relevant.

Use the Asc function to replace keys with values. If the Asc function encounters a blank string, LibreOffice Basic reports a run-time error. In addition to 7 bit ASCII characters (Codes 0-127), the ASCII function can also detect non-printable key codes in ASCII code. This function can also handle 16 bit unicode characters.

Error codes:

D'oh! You found a bug (text/sbasic/shared/00000003.xhp#err5 not found).


Sub ExampleASC
    Print ASC("A") REM แƒแƒ‘แƒ แƒฃแƒœแƒ”แƒ‘แƒก 65
    Print ASC(string:="Z") ' returns 90
    Print ASC("แƒšแƒแƒก แƒ•แƒ”แƒ’แƒแƒกแƒ˜") REM แƒแƒ‘แƒ แƒฃแƒœแƒ”แƒ‘แƒก 76, แƒ แƒแƒ’แƒแƒ แƒช แƒ™แƒ˜ แƒžแƒ˜แƒ แƒ•แƒ”แƒšแƒ˜ แƒกแƒ˜แƒ›แƒ‘แƒแƒšแƒ แƒแƒ แƒ˜แƒก แƒ›แƒฎแƒ”แƒ“แƒ•แƒ”แƒšแƒแƒ‘แƒแƒ˜
End Sub

Please support us!