Strings.Asc 方法 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回表示与某个字符相对应的字符代码的整数值。
重载
| Asc(Char) | 
						 返回表示与某个字符相对应的字符代码的整数值。  | 
        	
| Asc(String) | 
						 返回表示与某个字符相对应的字符代码的整数值。  | 
        	
Asc(Char)
- Source:
 - Strings.vb
 
- Source:
 - Strings.vb
 
- Source:
 - Strings.vb
 
返回表示与某个字符相对应的字符代码的整数值。
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
	参数
- String
 - Char
 
必需。 任何有效的 Char 或 String 表达式。 如果 String 是一个 String 表达式,则只将字符串的第一个字符用于输入。 如果 String 是 Nothing 或不包含任何字符,将会出现 ArgumentException 错误。
返回
与某个字符相对应的字符代码。
示例
以下示例使用 Asc 函数返回 Integer 对应于每个字符串中的第一个字母的字符代码。
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")
    	注解
              Asc 返回输入字符的 码位或字符代码。 对于 SBCS) 值 (单字节字符集,这可以是 0 到 255;对于双字节字符集 (DBCS) 值,可以为 -32768 到 32767。
              AscW 返回输入字符的 Unicode 码位。 这可以是 0 到 65535。 返回的值与当前线程的区域性和代码页设置无关。
注意
              AscB早期版本的 Visual Basic 函数返回字节的代码,而不是字符。 它主要用于转换双字节字符集 (DBCS) 应用程序中的字符串。 所有 Visual Basic 2005 字符串都在 Unicode 中, AscB 不再受支持。
另请参阅
- Chr(Int32)
 - ChrW(Int32)
 - System.Globalization
 - CultureInfo
 - ANSICodePage
 - ArgumentException
 - 函数 (Visual Basic)
 
适用于
Asc(String)
- Source:
 - Strings.vb
 
- Source:
 - Strings.vb
 
- Source:
 - Strings.vb
 
返回表示与某个字符相对应的字符代码的整数值。
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
	参数
- String
 - String
 
必需。 任何有效的 Char 或 String 表达式。 如果 String 是一个 String 表达式,则只将字符串的第一个字符用于输入。 如果 String 是 Nothing 或不包含任何字符,将会出现 ArgumentException 错误。
返回
与某个字符相对应的字符代码。
示例
以下示例使用 Asc 函数返回 Integer 对应于每个字符串中的第一个字母的字符代码。
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")
    	注解
              Asc 返回输入字符的 码位或字符代码。 对于 SBCS) 值 (单字节字符集,这可以是 0 到 255;对于双字节字符集 (DBCS) 值,可以为 -32768 到 32767。
              AscW 返回输入字符的 Unicode 码位。 这可以是 0 到 65535。 返回的值与当前线程的区域性和代码页设置无关。
注意
              AscB早期版本的 Visual Basic 函数返回字节的代码,而不是字符。 它主要用于转换双字节字符集 (DBCS) 应用程序中的字符串。 所有 Visual Basic 2005 字符串都在 Unicode 中, AscB 不再受支持。
另请参阅
- Chr(Int32)
 - ChrW(Int32)
 - System.Globalization
 - CultureInfo
 - ANSICodePage
 - ArgumentException
 - 函数 (Visual Basic)