Convert.ToDouble (Decimal) converts decimal number to double-precision floating-point number.
Module Example
Public Sub Main()
Dim decimalVal As Decimal = 123123.123123
Dim doubleVal As Double
' Decimal to Double conversion cannot overflow.
doubleVal = System.Convert.ToDouble(decimalVal)
System.Console.WriteLine("{0} as a Double is: {1}",decimalVal, doubleVal)
' Conversion from Double to Decimal can overflow.
Try
decimalVal = System.Convert.ToDecimal(doubleVal)
System.Console.WriteLine("{0} as a Decimal is: {1}",doubleVal, decimalVal)
Catch exception As System.OverflowException
System.Console.WriteLine("Overflow in Double-to-Decimal conversion.")
End Try
End Sub
End Module
Related examples in the same category