I need some help coding something. I'm quite new so...yeah.
CODE
Private Sub DistanceConvertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DistanceConvertButton.Click
'converts Distances to metric
Dim numInch As Decimal
Dim numFeet As Decimal
Dim numMile As Decimal
Dim numCenti As Decimal
Dim numMeter As Decimal
Dim numKilo As Decimal
If txtInch.Text <> " " Then
numInch = txtInch.Text * 2.54
txtCenti.Text = numInch
Else
numCenti = txtCenti.Text / 2.54
txtInch.Text = numCenti
End If
If txtFeet.Text <> " " Then
numFeet = txtFeet.Text * 0.3048
txtMeter.Text = numFeet
Else
numMeter = txtMeter.Text / 0.3048
txtFeet.Text = numMeter
End If
If txtMile.Text <> " " Then
numMile = txtMile.Text * 1.61
txtKilo.Text = numMile
Else
numKilo = txtKilo.Text / 1.61
txtMile.Text = numKilo
End If
End Sub
I'm trying to get this to work so that if I type some measurement in metric it will convert to US measurements, and if I type something in US measurements it will convert to Metric.
Before I up in all the If then statements it converted to US to metric just fine, though I don't know if the actual conversions were correct, but it worked anyway. Now it just give me an error saying IvalidCastException unhandled.
And I'm not sure what that means...