The VBA Asc Function

Related Function:


The VBA Asc function returns an integer representing the character code for the first character of a supplied string.

The syntax of the function is:

Asc( String )

Where the String argument is the text string for which you want the character code of the first character.

VBA Asc Function Examples

' Return the character codes for the first characters of three strings
Dim code1 As Integer
Dim code2 As Integer
Dim code3 As Integer
code1 = Asc( "a" )
' code1 is now equal to 97
code2 = Asc( "alpha" )
' code2 is now equal to 97
code3 = Asc( "Alpha" )
' code3 is now equal to 65

After running the above VBA code: