Converts any numeric type or String to a Double value.
...CDbl ( expression )
Prerequisites
None
Parameters
expression
A required numeric or string 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 s_val As Single
s_val = CInt(3.14159) ' Sets s_val equal to 3
s_val = CByte(300) ' WILL GENERATE AN ERROR
See Also