fr de es it nl pl pt pt_BR mk sq ca ar fa vi ja ru zh zh_TW eo
Home > lang > chr
 
Previous  Next  Edit  Rename  Undo  Refresh  Search  Administration   
Documentation
History
 
Chr$
Syntax
Character = Chr$ ( Code AS Integer ) AS String
Character = Chr ( Code AS Integer ) AS String

Returns the character whose ASCII code is Code.

Be careful! Gambas uses the UTF-8 charset internally, so character code greater than 128 have not the meaning they have with a charset like ISO 8859-1. This is a problem especially if you have to process special characters of some languages like the German umlauts. You might want to convert the string into ASCII using the Conv$() function before processing it.

Errors

MessageDescription
Bad argument (#20) Code is negative or greater than 255.

Examples

' This example prints the ASCII characte code 65 which is uppercase A
PRINT Chr$(65)

A

' This example prints the characters whose ascii code
' is between 32 and 127

DIM X AS Integer
FOR X = 32 TO 127
PRINT Chr$(X);
NEXT

' This example illustrates the use of special character. Here Chr$(10)
' works like the newline command.

PRINT "This will print on line 1"; Chr$(10); "This will print on line 2"

This will print on line 1 This will print on line 2

See also

String Functions