CDbl Function
Returns an expression that has been converted to a Variant of subtype Double.
Syntax
CDbl(expression)
Remarks
The expression argument is any valid expression.
Use the CDbl
function to provide internationally aware conversions
from any other data type to a Double subtype. For example, different decimal
separators and thousands of separators are properly recognized depending on the
locale setting of your system.
This example uses the CDbl
function to convert an expression to a
Double.
The following example illustrates the use of the CDbl
:
Example 1:
Dim MyDouble
MyDouble = CDbl(234.456784 * 8.2 * 0.01) ' Convert result to a Double (19.225456288).
'Output: 19.225456288
Example 2:
Dim MyInt
MyInt = 100 ' MyInt is an Integer.
MyDouble = CDbl(MyInt) ' Convert Integer to Double.
'Output: 100.0
Example 3:
Dim MyString
MyString = "123.456" ' MyString is a String.
MyDouble = CDbl(MyString) ' Convert String to Double.
'Output: 123.456
Example 4:
Dim Value1, Value2, Result
Value1 = 123.45 ' Double value.
Value2 = 67.89 ' Another Double value.
Result = CDbl(Value1 + Value2) ' Convert result to Double.
'Output: 191.34