Chr Function

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

Syntax:

Chr(Expression As Integer)

Return value:

Chuỗi

Parameters:

Expression: 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), Expression 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 , when VBA compatibility mode is enabled and expression 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 "một "+ Chr$(34)+"chuyến dã ngoại" + Chr$(34)+" ngắn."
            REM Chuỗi in xuất hiện trong hộp thoại như Một "chuyến dã ngoại" ngắn.
        End Sub
    

ASC

Please support us!