CStr

From Real Software Documentation

Jump to: navigation, search
Method

Use to convert the passed data type to a String.

You can also pass a class instance as long as the class implements the Operator_Convert method that returns a String. For real numbers, CStr returns 7 significant digits.

See the Str function for more information.


Syntax

result=CStr(Data)

Part Type Description
result String The string representation of the value passed.
data Variant The variable that will be represented as a string.

Notes

When you pass a real number to CStr, the string it returns uses the decimal separator the user specified in system preferences. The Str function does not.

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.

Examples

These examples return the string representation of two numbers and a Boolean.

Dim s as String
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.

Dim s As String
Const Pi=3.14159265358979323846264338327950
s= CStr(pi) // returns "3.141593"


See Also

CDbl, Str, Val functions; Boolean, Color, Date, String, Variant datatypes.

Personal tools