Chr, Chr$, ChrB, ChrB$, ChrW, ChrW$ (functions)

Syntax Chr[$](charcode) ChrB[$](charcode) ChrW[$](charcode)
Description Returns the character whose value is Code.
Comments The Chr$, ChrB$, and ChrW$ functions return a String, whereas the Chr, ChrB, and ChrW functions return a String variant. These functions behave differently depending on the string format used by BasicScript. These differences are summarized in the following table:
?? Function String Format ?? Value between ?? Returns a
Chr[$] SBCS 0 and 255 1-byte character string.
MBCS ??-32768 and 32767 1-byte or 2-byte MBCS character string depending on charcode.
Wide ??-32768 and 32767 2-byte character string.
ChrB[$] SBCS 0 and 255 1-byte character string.
MBCS 0 and 255 1-byte character string.
Wide 0 and 255 1-byte character string.
ChrW[$] SBCS 0 and 255 1-byte character string (same as the Chr and Chr$ functions)
MBCS -32768 and 32767 1-byte or 2-byte MBCS character string depending on charcode.
Wide ??-32768 and 32767 2-byte character string.
The Chr$ function can be used within constant declarations, as in the following example: Const crlf = Chr$(13) + Chr$(10) Some common uses of this function are:
Chr$(9) Tab
Chr$(13) + Chr$(10) End-of-line (carriage return, linefeed)
Chr$(26) End-of-file
Chr$(0) Null
Example

                           Sub Main()
                           ????????'Concatenates carriage return (13) and line feed (10) to
                           ????????'CRLF$, then displays a multiple-line message using CRLF$
                           ????????'to separate lines.
                           ????????crlf$ = Chr$(13) + Chr$(10)
                           ????????MsgBox "First line." & crlf$ & "Second line."
                           
                           
??
                           ????????'Fills an array with the ASCII characters for ABC and
                           ????????'displays their corresponding characters.
                           ????????Dim a%(2)
                           ????????For i = 0 To 2
                           ??????????a%(i) = (65 + i)
                           ????????Next i
                           ????????MsgBox "The first three elements of the array are: " _
                           ??????????& Chr$(a%(0)) & Chr$(a%(1)) & Chr$(a%(2))
                           End Sub
                        
See Also Asc, AscB, AscW (functions); Str, Str$ (functions).