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 Invalid procedure call

6 Overflow

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
    

Please support us!