Use to convert the passed data type to a String. Numbers are formatted using the system settings for numerical display.
|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.
These examples return the string representation of two numbers and a Boolean.
Dim d As New Date
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 example returns the approximation to Pi as a String to 7 significant digits.