From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
Use to convert the passed data type to a String. Numbers are formatted using the system settings for numerical display.
result = CStr(Data)
|result||String||The string representation of the value passed.|
|data||Variant||The variable that will be represented as a string.|
For real numbers, CStr returns 7 significant digits. When you pass a real number to CStr, the string it returns uses the decimal separator the user specified in system preferences. However, in most cases you will want to use the Format function instead for more precise control of the formatting. Use the Str function if you want to ensure US/English notation.
If you pass a Boolean, CStr 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 code returns the string representation of two numbers and a Boolean.
Var d As New DateTime = DateTime.Now
s = CStr(1) // returns "1", as a string
s = CStr(d.Day) // returns the day number as a string
s = CStr(True) // returns "True"
This code returns the approximation to Pi as a String to 7 significant digits.