Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Returns an Integer representing the character code corresponding to the first letter in a string.


Asc ( string )

The required stringargument is any valid string expression. If the string contains no characters, a run-time error occurs.


The range for returns is 0 – 255 on non-DBCS systems, but –32768 – 32767 on DBCS systems.

Note: 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. The AscW function returns the Unicode character code except on platforms where Unicode is not supported, in which case, the behavior is identical to the Asc function.

Note:  Visual Basic for the Macintosh does not support Unicode strings. Therefore, AscW(n) cannot return all Unicode characters for n values in the range of 128 – 65,535, as it does in the Windows environment. Instead, AscW(n) attempts a "best guess" for Unicode values n greater than 127. Therefore, you should not use AscW in the Macintosh environment.

Query examples



SELECT Asc("a") AS Expr1 FROM ProductSales;

Returns the "ASCII" code for the string "a". Result: "97".

SELECT Asc("Z") AS AscCode FROM ProductSales;

Returns the "ASCII" code for the string "Z" in the column AscCode. Result: "90".

VBA example

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

This example uses the Asc function to return a character code corresponding to the first letter in the string.

Dim MyNumber
MyNumber = Asc("A") ' Returns 65.
MyNumber = Asc("a") ' Returns 97.
MyNumber = Asc("Apple") ' Returns 65.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!