ChrW Function [VBA]

返回指定字符代码对应的 Unicode 字符。

warning

This constant, function or object is enabled with the statement Option VBASupport 1 placed before the executable program code in a module.


语法:


ChrW(charcode As Integer) As String

返回值:

字符串

参数:

charcode: Numeric expression that represent a valid 16 bit Unicode value (0-65535). (To support expressions with a nominally negative argument like ChrW(&H8000) in a backwards-compatible way, values in the range −32768 to −1 are internally mapped to the range 32768 to 65535.) An empty value returns error code 5. A value out of the range [0 to 65535] returns error code 6.

错误代码:

5 无效的过程调用

6 溢出

示例:


Sub ExampleChrW
    ' 本示例在字符串中插入希腊字母 alpha 与 omega。
    MsgBox "From " + ChrW(913) + " to " + ChrW(937)
    ' 弹出的消息框中会显示: 从 Α 到 Ω
    MsgBox ChrW(charcode := 116) ' "t" lowercase T letter
End Sub

请支持我们!