Strings.AscW 方法

定义

返回表示与某个字符相对应的字符代码的整数值。

重载

AscW(Char)

返回表示与某个字符相对应的字符代码的整数值。

AscW(String)

返回表示与某个字符相对应的字符代码的整数值。

AscW(Char)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

返回表示与某个字符相对应的字符代码的整数值。

public:
 static int AscW(char String);
public static int AscW (char String);
static member AscW : char -> int
Public Function AscW (String As Char) As Integer

参数

String
Char

必需。 任何有效的 CharString 表达式。 如果 String 是一个 String 表达式,则只将字符串的第一个字符用于输入。 如果 StringNothing 或不包含任何字符,将会出现 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 不再受支持。

另请参阅

适用于

AscW(String)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

返回表示与某个字符相对应的字符代码的整数值。

public:
 static int AscW(System::String ^ String);
public static int AscW (string String);
static member AscW : string -> int
Public Function AscW (String As String) As Integer

参数

String
String

必需。 任何有效的 CharString 表达式。 如果 String 是一个 String 表达式,则只将字符串的第一个字符用于输入。 如果 StringNothing 或不包含任何字符,将会出现 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 不再受支持。

另请参阅

适用于