Q:

Conversion string to double is not valid

following code gives error conversion from string to doble is not valid
Dim TaxRebate = CDbl(ComboBox1.SelectedItem) * 0.01 * CDbl(Premium)

help in to this is appreciated
Sunilsb

A:

'Dim TaxRebate = CDbl(ComboBox1.SelectedItem) * 0.01 * CDbl(Premium)

Dim value1 As String
Dim number1 As Double

Dim value2 As String
Dim number2 As Double

Dim TaxRebate As Double

value1 = ComboBox1.SelectedItem.ToString()
value2 = Premium.ToString()

If False = Double.TryParse(value1, number1) then
    Console.WriteLine("{0} is outside the range of a Double.", value1)
ElseIf False = Double.TryParse(value2, number2) Then
    Console.WriteLine("{0} is outside the range of a Double.", value2)
Else
    TaxRebate = 0.01 * number1 * number2 
End If

