hey im trying to create a program where the user will type in a number then choose the units its in and units it will be converted to from 2 comboboxes. The output should be changing as different units are clicked without a button.Please tell me how to fix my code and whats wrong with it.Thanks
Public Class Convert
Sub Calculate()
Dim Unit1 As Double = (ComboBox1.SelectedItem)
Dim Unit2 As Double = (ComboBox2.SelectedItem)
Dim Input As Long
lblValue.Text = Input * Unit1 / Unit2
End Sub
Function Change(ByVal Unit)
Select Case Unit
Case "Meter"
Return 1
Case "Nanometer"
Return 0.000000001
Case "Centimeter"
Return 0.01
Case "Millimeter"
Return 0.001
Case "Kilometer"
Return 1000
Case "Hectometer"
Return 100
Case "Inch"
Return 39.37
Case "Feet"
Return 0.3048
Case "Mile"
Return 1069.344
Case "Yard"
Return 0.9144
End Select
End Function
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Call Calculate()
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Call Calculate()
End Sub
Private Sub Input_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Input.TextChanged
Call Calculate()
End Sub
End Class