From Xojo Documentation

Revision as of 19:16, 19 November 2009 by WikiSysop (talk) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!


Returns the string form of the value passed.



Part Type Description
result String The string version of the value passed. For numbers, it returns the number as a string. For dates, it returns the date as a string in SQL date/time format, YYYY-MM-DD HH:MM:SS. For Colors, it returns the string value of the Color as a Hex number in the format, &hRRGGBB.
value Numeric, Boolean, Date, or Color Any numeric, Boolean, Date or Color expression.


Use the Format function when you want to convert numeric values into formatted strings such as dates, times, currency, etc. For real numbers, Str returns 7 significant digits. Str assumes that the period (.) is the decimal separator. If your application needs to recognize other decimal separators, use the CStr function.

If you pass a Boolean, Str will return either the string "True" or "False". If you pass a Color, it will return the hex representation of the color as a String. If you pass a Date, it will return the value of the date in SQL Date-time format.


This example uses the Str function to return the string form of several numbers.

Dim s As String
s=Str(123) //returns "123"
s=Str(-123.44) //returns "-123.44"
s=Str(123.0045) //returns "123.0045"
Const Pi=3.14159265358979323846264338327950
s= Str(pi) // returns "3.141593"
s= Str(3141592653589012345) // returns "3141592653589012345"
s=Str("True") //returns True
//displaying the system Dark Tinge Color as a hex number
Dim c as Color
MsgBox Str(c)

//obtaining the current date/time as a string
Dim d as New Date
MsgBox Str(d)

See Also

Boolean, Color, Date datatypes; CDbl, CStr, Format, Val functions.