Str
Returns a string representation of a number, boolean or Unicode character string
Syntax
`
Declare Function Str ( ByVal n As Byte ) As String
Declare Function Str ( ByVal n As UByte ) As String
Declare Function Str ( ByVal n As Short ) As String
Declare Function Str ( ByVal n As UShort ) As String
Declare Function Str ( ByVal n As Long ) As String
Declare Function Str ( ByVal n As ULong ) As String
Declare Function Str ( ByVal n As LongInt ) As String
Declare Function Str ( ByVal n As ULongInt ) As String
Declare Function Str ( ByVal n As Single ) As String
Declare Function Str ( ByVal n As Double ) As String
Declare Function Str ( ByVal b As Boolean ) As String
Declare Function Str ( ByRef str As Const String ) As String
Declare Function Str ( ByVal str As Const WString ) As String
`
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 dialect.
- The string type suffix "$" is forbidden in the -lang fb dialect.

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

- `Val`
- `CBool`
- `Chr`
- `Asc`