CDbl Function in VB.NET

How to convert a string to double in VB.Net?

Explanation

CDbl Function - Convert String to Double

CDbl Function in Visual Basic.net 2008 is used convert a string expression into Double datatype. This function uses the locale settings to determine how to convert datatypes.
Syntax:

CDbl(expression)
Example:

Module Module1
Sub Main()
Dim x As Integer = 3.5
Dim y As Integer = 3
Console.WriteLine("Value converted to double datatype
is::" & CDbl(x / y))
Console.ReadLine()
End Sub
End Module
Result:

Value converted to double datatype is::1.33333333333333

In the above example, an integer expression is converted to double datatype.

Visual Basic Tutorial


Ask Questions

Ask Question