Help Center›FreeBASIC
Strfunction
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
Parameters
| Name | Description | |
|---|---|---|
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.Remarks
Usage
result = Str[$]( number )
or
result = Str( string )
Dialect Differences
- In the -lang qb dialect,
Strwill left pad a positive number with a space.
- 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).
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
Example
Dim a As Integer
Dim b As String
a = 8421
b = Str(a)
Print a, b
Reference
- Documented in KeyPgStr.html