Text Documents (Writer)
HTML Documents (Writer Web)
Spreadsheets (Calc)
Presentations (Impress)
Drawings (Draw)
Database Functionality (Base)
Formulae (Math)
Charts and Diagrams
Macros and Scripting
Office Installation
Common Help Topics
OneOffice Logo

Asc Function (BASIC)

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

Syntax:


Asc(string) As Long

Return value:

Long

Parameters:

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, Office 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:

5 Invalid procedure call

Example:


Sub ExampleASC
    Print ASC("A") ' returns 65
    Print ASC(string:="Z") ' returns 90
    Print ASC("Blackpool") ' returns 66, since only the first character is taken into account
End Sub