Chr Function

Повертає символ, відповідний вказаному кодові таблиці символів.

Синтаксис:


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

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$ використовується для надсилання спеціальних керівних послідовностей на принтер або на інші пристрої виводу. Вона також може використовуватися для вставки лапок в рядок.

Коди помилок:

5 Неправильний виклик процедури

6 Переповнення

note

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."
            ' У діалоговому вікні це буде виглядати як: Це "короткий" рядок.
            MsgBox Chr(charcode := 64) ' "@" sign
        End Sub
    

Будь ласка, підтримайте нас!