Skip to main content

Asc function

Table of contents
  1. Syntax
  2. Remarks
  3. Example

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



The required string argument 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.

The functions Chr(), ChrB(), and ChrW() are the opposite of Asc(), AscB(), and AscW(). The Chr() functions convert an integer to a character string.


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.

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>