LibreOffice 24.8 帮助
返回与指定字符代码对应的字符。
Chr[$](charcode As Integer) As String
String
charcode: a numeric expression that represents a valid 8-bit ASCII value (0-255) or a 16-bit Unicode value. (To support expressions with a nominally negative argument like Chr(&H8000) in a backwards-compatible way, values in the range −32768 to −1 are internally mapped to the range 32768 to 65535.)
When VBA compatibility mode is enabled (Option VBASupport 1), charcode is a numeric expression that represents a valid 8-bit ASCII value (0-255) only.
利用「Chr$」函数,可以将特殊的控制序列发送到打印机或其他输出源。还可以利用该函数在字符串表达式中插入引号。
An overflow error will occur when VBA compatibility mode is enabled and the expression value is greater than 255.
Sub ExampleChr
' 此示例在字符串中插入引号 (ASCII 值为 34)。
MsgBox "A " + Chr$(34) + "short" + Chr(34) + " trip."
' 对话框中的输出为: A "short" trip。
MsgBox Chr(charcode := 64) ' "@" sign
End Sub