CDbl
From Real Software Documentation
Method
Returns the numeric equivalent of the passed string. This function is the same as the Val function but is international-savvy.
Notes
Use Val if you control the string that is passed, and use CDbl if the string comes from the user. You should use CDbl instead of Val if the string contains separators.
See the Val function for more information.
Syntax
result=Cdbl(string)
OR
Introduced 5.0 result=stringVariable.CDbl
| Part | Type | Description |
|---|---|---|
| result | Double | The numeric equivalent of the string passed, if a numeric equivalent exists. |
| string | String | Any valid string expression. |
| stringVariable | String | Any variable of type String. |
Notes
CDbl returns zero if string contains no numbers, except in the special case where the string begins with the string “NAN”. In this case, it returns “NAN(021)”.
Examples
These examples use the CDbl function to return the numbers contained in a string.
Dim n As Double
n = CDbl("12345") //returns 12345
n = CDbl("54.05car45") //returns 54.05
n = CDbl("123.45") //returns 123.45
n = CDbl("123 45") //returns 123
n = CDbl("123,456") //returns 123456
n = CDbl("auto") //returns 0
n = CDbl("12345") //returns 12345
n = CDbl("54.05car45") //returns 54.05
n = CDbl("123.45") //returns 123.45
n = CDbl("123 45") //returns 123
n = CDbl("123,456") //returns 123456
n = CDbl("auto") //returns 0
n = CDbl("&hFFF") //returns 4095
n = CDbl("&b1111") //returns 15
n = CDbl("&b1111") //returns 15
This example shows both syntaxes of CDbl.
