Chr Function

Trả về ký tự tương ứng với mã ký tự đã ghi rõ.

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.


Hãy sử dụng hàm Chr$ để gửi các dãy điều khiển đặc biệt cho một máy in hay nguồn xuất khác. Bạn cũng có thể sử dụng nó để chèn dấu nháy kép vào một biểu thức chuỗi.

Error codes:

5 Sai gọi thủ tục

6 Tràn 6 Tràn

note

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


Example:


        Sub ExampleChr
            REM Mẫu thí dụ này chèn dấu nháy kép (giá trị ASCII 34) vào một chuỗi.
            MsgBox "A " + Chr$(34) + "short" + Chr(34) + " trip."
            REM Chuỗi in xuất hiện trong hộp thoại như Một "chuyến dã ngoại" ngắn.
            MsgBox Chr(charcode := 64) ' "@" sign
        End Sub
    

Please support us!