Chr Function

指定された文字コードに対応する文字を返します。

Syntax:


      Chr[$](charcode As Integer) As String
    

Return value:

String

Parameters:

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.)

warning

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$ 関数は、プリンターなどの出力装置に対して、制御用の特殊なシーケンスを送信する際に使用します。また文字列中に引用符を挿入する場合にも使用できます。

Error codes:

5 無効なプロシージャー呼び出しです

6 オーバーフローです

note

An overflow error will occur when VBA compatibility mode is enabled and the expression value is greater than 255.


Example:


        Sub ExampleChr
            REM このサンプルは、引用符 (ASCII 値 34) を文字列中に挿入します。
            MsgBox "A " + Chr$(34) + "short" + Chr(34) + " trip."
            REM ダイアログには A "short" trip. と表示されます。
            MsgBox Chr(charcode := 64) ' "@" sign
        End Sub
    

ご支援をお願いします!