Purpose
Returns a string representing an expression (for example, a printout of a number). You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Str$( expression )
expression is a numeric, Date, Pen, Brush, Symbol, Font, logical, or Object expression.
Return Value
String
Description
The Str$() function returns a string which represents the value of the specified expression.
If expression is a negative number, the first character in the returned string is the minus sign (-). If expression is a positive number, the first character in the string is a space.
Depending on the number of digits of accuracy in the expression you specify, and depending on how many of the digits are to the left of the decimal point, the Str$() function may return a string which represents a rounded value. If you need to control the number of digits of accuracy displayed in a string, use the Format$() function.
If expression is an Object expression, the Str$() function returns a string, indicating the object type: Arc, Ellipse, Frame, Line, Point, Polyline, Rectangle, Region, Rounded Rectangle, or Text.
If expression is an Object expression of the form tablename.obj and if the current row from that table has no graphic object attached, Str$() returns a null string.
If expression is a Date, the output from Str$() depends on how the user's computer is configured. For example, the following expression:
Str$( NumberToDate(19951231) )
might return "12/31/1995" or "1995/12/31" (etc.) depending on the date formatting in use on the user's computer. To control how Str$() formats dates, use the Set Format statement.
If expression is a number, the Str$() function uses a period as the decimal separator, even if the user's computer is set up to use another character as decimal separator. The Str$() function never includes thousands separators in the return string. To produce a string that uses the thousands separator and decimal separator specified by the user, use the FormatNumber$() function.
Example
Dim s_spelled_out As String, f_profits As Float
f_profits = 123456
s_spelled_out = "Annual profits: $" + Str$(f_profits)
See Also:
Format$() function, FormatNumber$() function, Set Format statement, Val() function