Skip to content
Paul Squires edited this page Oct 19, 2026 · 3 revisions

Home › String Functions › Chr

Chr

Returns a string made from one or more character codes.

Syntax

Declare Function Chr ( ByVal ch As Integer [, ... ] ) As String

Parameters

  • ch

Description

Chr returns a string containing the character(s) represented by the ASCII values passed to it.

When Chr is used with numerical constants or literals, the result is evaluated at compile-time, so it can be used in variable initializers.

Asc performs the opposite function, returning the ASCII code of a character represented by a string.

Return Value

Returns a string containing the character(s).

Remarks

Usage

result = Chr[$]( ch0 [, ch1 ... chN ] )

Dialect Differences

  • The string type suffix "$" is required in the -lang qb dialect. The string type suffix "$" is optional in the -lang fblite dialect.
    The string type suffix "$" is ignored in the -lang fb dialect, warn only with the -w suffix compile option (or -w pedantic compile option).

Differences from QB

  • FreeBASIC accepts multiple integer values as arguments, QB accepted only one.
  • FreeBASIC evaluates the CHR function at compile time when used with constants or literals.

See also

Examples

Print "the character represented by";

Print " the ASCII code of 97 is: "; Chr(97)

Print Chr(97, 98, 99) ' prints abc

' s initially has the value "abc"

Dim s As String = Chr(97, 98, 99)

Print s

Category: String Functions
Kind: function


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally