Returns an integer value representing the character code corresponding to a character.
Overloads Asc(Char)Returns an integer value representing the character code corresponding to a character.
Asc(String)Returns an integer value representing the character code corresponding to a character.
Asc(Char)Returns an integer value representing the character code corresponding to a character.
public:
static int Asc(char String);
public static int Asc(char String);
static member Asc : char -> int
Public Function Asc (String As Char) As Integer
Parameters
Required. Any valid Char
or String
expression. If String
is a String
expression, only the first character of the string is used for input. If String
is Nothing
or contains no characters, an ArgumentException error occurs.
The character code corresponding to a character.
ExamplesThe following example uses the Asc
function to return Integer
character codes corresponding to the first letter in each string.
Dim codeInt As Integer
' The following line of code sets codeInt to 65.
codeInt = Asc("A")
' The following line of code sets codeInt to 97.
codeInt = Asc("a")
' The following line of code sets codeInt to 65.
codeInt = Asc("Apple")
Remarks
Asc
returns the code point, or character code, for the input character. This can be 0 through 255 for single-byte character set (SBCS) values and -32768 through 32767 for double-byte character set (DBCS) values.
AscW
returns the Unicode code point for the input character. This can be 0 through 65535. The returned value is independent of the culture and code page settings for the current thread.
Note
The AscB
function of earlier versions of Visual Basic returns a code for a byte, rather than a character. It is used primarily for converting strings in double-byte character set (DBCS) applications. All Visual Basic 2005 strings are in Unicode, and AscB
is no longer supported.
Returns an integer value representing the character code corresponding to a character.
public:
static int Asc(System::String ^ String);
public static int Asc(string String);
static member Asc : string -> int
Public Function Asc (String As String) As Integer
Parameters
Required. Any valid Char
or String
expression. If String
is a String
expression, only the first character of the string is used for input. If String
is Nothing
or contains no characters, an ArgumentException error occurs.
The character code corresponding to a character.
ExamplesThe following example uses the Asc
function to return Integer
character codes corresponding to the first letter in each string.
Dim codeInt As Integer
' The following line of code sets codeInt to 65.
codeInt = Asc("A")
' The following line of code sets codeInt to 97.
codeInt = Asc("a")
' The following line of code sets codeInt to 65.
codeInt = Asc("Apple")
Remarks
Asc
returns the code point, or character code, for the input character. This can be 0 through 255 for single-byte character set (SBCS) values and -32768 through 32767 for double-byte character set (DBCS) values.
AscW
returns the Unicode code point for the input character. This can be 0 through 65535. The returned value is independent of the culture and code page settings for the current thread.
Note
The AscB
function of earlier versions of Visual Basic returns a code for a byte, rather than a character. It is used primarily for converting strings in double-byte character set (DBCS) applications. All Visual Basic 2005 strings are in Unicode, and AscB
is no longer supported.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4