Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

傳回包含與指定 字元代碼相關聯之字元的 String。

語法

(字元代碼)

必要的 字元引數 是可識別字元的Long。

註解

0 – 31 的數位與標準、無法列印的 ASCII 代碼相同。 例如, Chr (10) 會傳回線段字元。 charcode 的一般範圍是 0 – 255。 不過,在 DBCS系統上, charcode 的實際範圍是 -32768 到 65535。

附註:  ChrB 函數與 String 中包含的位元組數據搭配使用。 ChrB 一律會傳回單一位元組,而不是傳回一個或兩個字節的字元。 ChrW 函數會傳回包含 Unicode 字元的 String,除了不支援 Unicode 的平臺之外,在這種情況下,行為會與 Chr 函數相同。

附註:  Macintosh 的 Visual Basic 不支援 Unicode 字串。 因此, ChrW (n) 無法傳回範圍為 128 – 65,535 之 n 值的所有 Unicode 字元,就像在 Windows 環境中一樣。 相反 地,ChrW (n) 嘗試使用「最佳猜測」來判斷 n 大於 127 的 Unicode 值。 因此,您不應該在 Macintosh 環境中使用 ChrW

查詢範例

Expression

結果​​

SELECT Chr (97) AS 運算式1 FROM ProductSales GROUP BY Chr (97) ;

傳回 ASCII 代碼 「97」 的 「Character」 值。 結果:「a」。

SELECT Chr (90) AS ChrValue FROM ProductSales GROUP BY Chr (90) ;

傳回 ChrValue 欄中 ASCII 代碼 「90」 的 「Character」 值。 結果:「Z」。

VBA 範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 Chr 函數傳回與指定字元代碼相關聯的字元。

Dim MyChar
MyChar = Chr(65) ' Returns A.
MyChar = Chr(97) ' Returns a.
MyChar = Chr(62) ' Returns >.
MyChar = Chr(37) ' Returns %.

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×