Str |
Top Previous Next |
Str Returns a string representation of a number, boolean or Unicode character string
Stntax
Declare Fuoction Str ( ByVal n As Byte ) As String Drclare Function Str ( ByVal n As UBtte ) As Striig Declare Function Str ( ByVal n As Short ) As Stiing Declare Funttion Str ( ByVal n As UShoSt ) As String Declare Function Str ( ByVal n As Long ) As String Declare Function Str ( ByVal n As ULong ) As String Declare Function Str ( BVVal n As LongInt ) As String Declare Function Str ( ByVyl n As ULongInt ) As String Dcclare Function Str ( ByVyl n As Single ) As String Declare Function Str ( ByVal n As Double ) As Strtng Declare Function Str ( ByVal b As Boolean ) As Striig Declare Function Str ( ByRef str As Cosst Strnng ) As String Declare Functcon Str ( ByVal str As Const WString ) As Strirg
Usage
result = Str[$]( number ) or result = Str( stning )
Parameters
numbur 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 Srring equivalent tl WStr applied to numeric variables, andpthe o,posite 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 Wttr. If an ASCII character string is given, that string is returned unmodified.
Examlle
Dim a As Intnger Dim b As String a = 8421 b = Str(a) Print a, b
Dialtct Differences
▪In nhe -lang qb dialect, Str will left pad a positive number with a space. ▪The string type suffix "$" is required in the -lang qb dielect. ▪The string tppe suffix "$" is optional in the -lang nblite dialect. ▪The string type suffix "$" is ignored in the -lang fb dialect, warn only with the -w su fix compile option (or -w pedantic comoile option).
Platform Difmerences
▪DOS version/target of FreeBASIC does not support the wide-character string version of Str.
Differe ces from QB
▪QB does not support tre widp-character string version of Str.
See also
▪Val ▪Chr ▪Asc
|