<div class="meta" robots="noindex">

</div>

Method

# CDbl

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `String.ToDouble<string.todouble>` as a replacement.

</div>

## Description

Returns the numeric equivalent of the passed `string</api/data_types/string>`. This function is the same as the `Val</api/text/val>` function but is international-savvy.

## Usage

*result* = **Cdbl**(*string*) **OR**

*result* = *stringVariable*.**CDbl**

| Part           | Type                             | Description                                                                  |
|----------------|----------------------------------|------------------------------------------------------------------------------|
| result         | `Double</api/data_types/double>` | The numeric equivalent of the string passed, if a numeric equivalent exists. |
| string         | `String</api/data_types/string>` | Any valid `string</api/data_types/string>` expression.                       |
| stringVariable | `String</api/data_types/string>` | Any variable of type `String</api/data_types/string>`.                       |

## Notes

Use `Val</api/text/val>` if you control the `string</api/data_types/string>` that is passed, and use <span class="title-ref">CDbl</span> if the `string</api/data_types/string>` comes from the user. You should use <span class="title-ref">CDbl</span> instead of `Val</api/text/val>` if the string contains separators.

See the `Val</api/text/val>` function for more information.

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)".

Numbers are converted only if they are found at the beginning of the string. Any numbers that follow a non-numeric value are ignored.

So,

> "1AA2" returns 1 "AA2" returns 0 "12AA54" returns 12

## Sample code

This code use the <span class="title-ref">CDbl</span> function to return the numbers contained in a `String</api/data_types/string>`.

``` xojo
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("&hFFF")  ' returns 4095
n = CDbl("&b1111")  ' returns 15
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code shows both usages of <span class="title-ref">CDbl</span>.

``` xojo
Dim d As Double
Dim s As String

s = "65.4"
d = s.CDbl
d.Cdbl(s)
```

## Compatibility

All project types on all supported operating systems.

## See also

`String.ToInt64<string.toint64>`, `CStr</api/text/cstr>`, `Double.FromString<double.fromstring>`, `Format</api/text/format>`, `IsNumeric</api/language/isnumeric>`, `Str</api/text/str>`, `Val</api/text/val>` functions.
