Name
CDbl Function
Syntax
CDbl(expression
)
-
expression
Use: Required
Data Subtype: Numeric or String
-1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.
Return Value
expression
cast as a Variant with a Double
subtype.
Description
Converts expression
to a Variant with a
Double subtype.
Rules at a Glance
If the value of
expression
is outside the range of the double datatype, an overflow error is generated.Expression must evaluate to a numeric value; otherwise, a type mismatch error is generated.
Example
Dim dblMyNumber as Double If IsNumeric(sMyNumber) then dblMyNumber = CDbl(sMyNumber) End If
Programming Tips & Gotchas
Use IsNumeric
to test whether
expression
evaluates to a number.
See Also
IsNumeric Function |
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.