Converts any numeric type to a String value.
...CStr ( expression )
Prerequisites
None
Parameters
expression
A required numeric expression. The numeric expression can yield any type of result, i.e. Boolean, Byte, Double, Integer, Short or Single.
Remarks
The conversion operators are a group of functions that convert an expression that evaluates to any numeric or string type into a specified data type. The conversion tests that the converted value falls within the proper range of values for the returned data type. If the converted value is out of range, and error is generated.
As opposed to the Int and Fix functions, the conversion functions convert real numbers to integers by rounding rather than truncation.
The table below summarizes all of the conversion functions.
Function | Returned Data Type | Range of Valid Expression Values |
---|---|---|
Boolean |
Any 0 or non-zero value |
|
Byte |
0 to 255 |
|
Double |
-1.79769313486231E+308 to |
|
Integer |
-2,147,483,648 to 2,147,483,647 |
|
Short |
-32768 to 32767 |
|
Single |
-3.402823E+38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E+38 for positive values. |
|
String |
Any valid Double value |
|
String |
Any valid Integer value |
Examples
Dim stg As String
stg = CStr(3.14159) ' Sets stg equal to "3.14159"
See Also