ASC Function (VBA)In Microsoft Excel, the ASC function returns the ASCII value of a character or the first character in a string.
SyntaxThe syntax for the ASC function is: Asc( string )
string is the specified character to retrieve the ASCII value for. If there is more than one character, the function will return the ASCII value for the first character and ignore all of the characters after the first.
VBA Function ExampleHere are some examples of what the ASC function would return:
Asc ("W") would return 87
Asc ("Wednesday") would return 87
Asc ("x") would return 120
Dim iResult As Integer iResult = Asc ("W")
In this example, the variable called iResult would now contain the value 87.
CHR Function (VBA)
In Microsoft Excel, the CHR function returns the character based on the ASCII value.
SyntaxThe syntax for the CHR function is: Chr( ascii_value )
ascii_value is the ASCII value used to retrieve the character.
VBA Function Example
Dim sResult As String sResult = Chr(87)
In this example, the variable called sResult would now contain the value "W".