CDbl

Coerces an expression to a Double.

Syntax: CDbl( expression )

expression
required Any valid string or numeric expression in the Double range — -1.79769313486231E308 to -4.94065645841247E-324 for negative values, and 4.94065645841247E-324 to 1.79769313486232E308 for positive values.

The return type is Double.

CDbl is the internationally aware alternative to Val for converting a string to a numeric type. CDbl recognizes different decimal separators and different thousand separators properly, depending on the system’s locale setting.

Common Errors

Error When
6 (&H6), Overflow expression is a string that holds a number outside the range of a Double
13 (&HD), Type mismatch expression is a string that does not hold a number (a zero-length string included)
94 (&H5E), Invalid use of Null expression is Null

Example

This example uses the CDbl function to convert an expression to a Double.

Dim MyCurr, MyDouble
MyCurr = CCur(234.456784)                    ' MyCurr is a Currency.
MyDouble = CDbl(MyCurr * 8.2 * 0.01)         ' Convert result to a Double.

See Also