STR$ function

Purpose: STR$ converts a number to a string.


 RetStr$ = STR$(Number[,NoSpace%])


  • Number Integer or floating point literal or variable.
  • NoSpace%[OPTIONAL] The default no argument or 0 indicates that a space is prepended to the returned string if the Number is positive. If NoSpace% is 1 then the space will not be prepended to the RetStr$.

Return Value:

  • RetStr$, the return value, is a string converted from the Number parameter argument.


By default, a space is prepended to the returned string if the number is positive and the optional NoSpace% parameter is empty or 0. This space is the location for the sign part of the number. When the Number argument is a negative number, a minus sign will be there.


  DIM RetStr$
  RetStr$ = STR$(3.14159)
  PRINT DQ$ & RetStr$ & DQ$
  RetStr$ = STR$(-3.14159)
  PRINT DQ$ & RetStr$ & DQ$

  RetStr$ = STR$(3.14159, 1)
  PRINT DQ$ & RetStr$ & DQ$


" 3.14159" 

BCX Console Sample Programs using STR$ function.

S04.bas, S10.bas, S19.bas, S24.bas, S54.bas, S70.bas, S89.bas, S92.bas, S107.bas