Asc function
Returns an Integer representing the character code corresponding to the first letter in a string.
Syntax
Asc(string)
The required string argument is any valid string expression. If the string contains no characters, a run-time error occurs.
Remarks
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.
The functions Chr(), ChrB(), and ChrW() are the opposite of Asc(), AscB(), and AscW(). The Chr() functions convert an integer to a character string.
Example
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.
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기