Str

FreeBASIC

Str
 
Returns a string representation of a number, boolean or Unicode character string

Syntax
Usage

result = Str[$]( number )
or
result = Str( string )

Parameters

number
Numeric expression to convert to a string.
string
String expression to convert to a string.

Description

Str converts numeric variables to their string representation. Used this way it is the String equivalent to WStr applied to numeric variables, and the opposite of the Val function, which converts a string into a number.

Str converts boolean variables to their string representation "false" / "true".

Str also converts Unicode character strings to ASCII character strings. Used this way it does the opposite of WStr. If an ASCII character string is given, that string is returned unmodified.

Example

Dim a As Integer
Dim b As String
a = 8421
b = Str(a)
Print a, b


Dialect Differences

  • In the -lang qb dialect, Str will left pad a positive number with a space.
  • The string type suffix "$" is obligatory in the -lang qb dialect.
  • The string type suffix "$" is optional in the -lang fblite and -lang fb dialects.

Platform Differences

  • DOS version/target of FreeBASIC does not support the wide-character string version of Str.

Differences from QB

  • QB does not support the wide-character string version of Str.

See also