CDBL

CDBL(expression)

Returns the expression converted to a double data type (Double).


expressionThe expression to evaluate and convert to a double.

REMARKS
* The Double data type is a Value data type.
* The "expression" can be any number between -1.8 E+308 and +4.9 E+324.
* If "expression" cannot be converted to a number you will get a type mismatch error.
* If "expression" is outside this range, then an error occurs.
* This function uses the locale setting to identify the different decimal separators and thousand separators.
* You can use the CINT function to return an expression converted to an Integer data type.
* You can use the CLNG function to return an expression converted to a Long data type.
* You can use the CSNG function to return an expression converted to a Single data type.
* For a full list of conversion functions refer to the Explicit Conversion page.
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print CDbl(30)            '= 30  
Debug.Print CDbl("0.00") '= 0
Debug.Print CDbl(#01/07/77#) '= 28132
Debug.Print CDbl("-100") '= -100
Debug.Print CDbl("100-") '= -100

Dim dbNumber As Double
Dim iNumber As Integer
iNumber = 20
dbNumber = CDbl(iNumber)
Debug.Print dbNumber
Debug.Print TypeName(dbNumber) '= "Double"

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top