Returns the ANSI number for the first character in a text string (Integer).

stringThe text string (String).

* The "string" can be any valid string expression.
* If string = "", then a run-time error occurs.
* The value returned is in the range 0 to 255.
* The length of a string in bytes may be greater than or equal to the number of actual characters in the string.
* Use Asc("y") = x rather than Chr(y) = x
* Use IsCharAlphaNumeric instead of Asc() ?
* The value returned is in the range -32768 - 32767 for Double Byte Character Sets.
* VBA for Macintosh does not support Unicode Strings.
* You can use the CHR function to return the character with the corresponding ANSI number.
* You can use the ASCB function to return the first byte.
* You can use the ASCW function to return Unicode number for the first character in a text string.
* The equivalent .NET function is Microsoft.VisualBasic.Strings.Asc
* For the Microsoft documentation refer to

Debug.Print Asc(0)           '= 48  
Debug.Print Asc(1) '= 49
Debug.Print Asc(9) '= 57
Debug.Print Asc("A") '= 65
Debug.Print Asc("Z") '= 90
Debug.Print Asc("a") '= 97
Debug.Print Asc("z") '= 122
Debug.Print Asc("Avocados") '= 65
Debug.Print Asc(12) '= 49

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top