Skip to Content

CHR$

A function which returns a string of length 1 containing the ASCII character specified by the least significant byte of the numeric argument.

A$=CHR$(72) B$=CHR$(12) C$=CHR$(A/200)

CHR$ generates an ASCII character (symbol, letter, number character, control character, etc) from the number given. The number specifies the position of the generated character in the ASCII table (See Annex A). For example:

char$=CHR$(65)

will set char$ equal to the character ‘A’. You can use CHR$ to send a special character to the terminal or printer. (Generally, VDU is better for sending characters to the screen.) For example,

CHR$(7)

will generate the ASCII character ^G. So,

PRINT "ERROR"+CHR$(7)

will print the message ‘ERROR’ and sound the PC’s ‘bell’. CHR$ is the complement of ASC.

Syntax

<s-var>=CHR$(<numeric>)

Associated Keywords

ASC, STR$, VAL, VDU

Last updated on