Strings.AscW 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳一個整數值,代表對應字元的字元代碼。
多載
| 名稱 | Description |
|---|---|
| AscW(Char) |
回傳一個整數值,代表對應字元的字元代碼。 |
| AscW(String) |
回傳一個整數值,代表對應字元的字元代碼。 |
AscW(Char)
回傳一個整數值,代表對應字元的字元代碼。
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
必須的。 任何有效的 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。 回傳的值與當前執行緒的文化與代碼頁設定無關。
備註
早期版本的 Visual Basic AscB 函式會回傳一個位元組的程式碼,而非字元。 其主要用於在雙位元組字元集 (DBCS) 應用程式中轉換字串。 所有 2005 Visual Basic字串皆為 Unicode,且不再支援 AscB。
另請參閱
- Chr(Int32)
- ChrW(Int32)
- System.Globalization
- CultureInfo
- ANSICodePage
- ArgumentException
- Functions (Visual Basic)
適用於
AscW(String)
回傳一個整數值,代表對應字元的字元代碼。
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
必須的。 任何有效的 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。 回傳的值與當前執行緒的文化與代碼頁設定無關。
備註
早期版本的 Visual Basic AscB 函式會回傳一個位元組的程式碼,而非字元。 其主要用於在雙位元組字元集 (DBCS) 應用程式中轉換字串。 所有 2005 Visual Basic字串皆為 Unicode,且不再支援 AscB。
另請參閱
- Chr(Int32)
- ChrW(Int32)
- System.Globalization
- CultureInfo
- ANSICodePage
- ArgumentException
- Functions (Visual Basic)