Chr Function

Description

Returns the character associated with the specified character code.

Syntax

Chr(charcode)

The charcode named argument is a number in the range 0 to 255, inclusive, that identifies a character.

Remarks

Numbers from 0 to 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character.

See Also

Asc Function, Str Function.

Example

This example uses the Chr function to return the character associated with the specified character code.


MyChar = Chr(65)    ' Returns A.
MyChar = Chr(97)    ' Returns a.
MyChar = Chr(62)    ' Returns >.
MyChar = Chr(37)    ' Returns %.

This example fills list box one on Dialog1 with the letters A through Z.


For i = 65 To 90
    DialogSheets("Dialog1").ListBoxes(1).AddItem Text:=Chr(i)
Next i

This example creates a line break in a message box by using the Chr function.


msgText = "The current folder is:" & Chr(13) & CurDir()
MsgBox msgText