Module Example
Public Sub Main()
Dim values() As Object = { True, "a"c, 123, CSng(112.764e32), "1239.78", "1e-02", _
Decimal.MaxValue }
Dim result As Double
For Each value As Object In values
Try
result = Convert.ToDouble(value)
Console.WriteLine("Converted the {0} value {1} to {2}.", _
value.GetType().Name, value, result)
Catch e As FormatException
Console.WriteLine("FormatException")
Catch e As InvalidCastException
Console.WriteLine("InvalidCastException")
End Try
Next
End Sub
End Module