STR$

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > BuiltIn Functions > String functions >

STR$

 

Description

 

Return the string representation of a number in printable form.

 

Syntax

 

s = STR$(NumericExpression [, Digits])

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

NumericExpression

Numeric

No

Any numeric expression to be transformed to string

Digits

Numeric

Yes

Specifies the maximum number of significant digits (1 to 18) desired in the result.

 

Remarks

 

If NumericExpression is greater than or equal to zero, STR$ adds a leading space character; if NumericExpression is less than zero, STR$ adds a leading negation (minus) character.

See TSTR$ for a trimmed version of STR$

 

Restrictions

 

See also

 

TSTR$,

 

Examples

 

Thanks to Abraxas for the following script example

' Usage of the STR$ Keyword example

 

Dim numeric_expression As EXT VALUE 123.4567890123456

Dim digits As DWORD

Dim sMsg   As String

 

sMsg += "Different STR$(numeric_expression, digits) of " & numeric_expression & $CRLF

sMsg += "Digits will be from 1 to 18" & $CRLF & $CRLF

 

For digits = 1 To 18

  sMsg += "Digit = " & digits & " Result: " & STR$(numeric_expression, digits) & $CRLF

Next

 

MSGBOX 0, sMsg