lundi 4 mai 2015

If statement not working properly in vb.net

The If statement i created doesn't work properly. It only works for the first sb condition for every condition. For example if Combobox2.text = "Running " and Combobox3.Text ="6mph" it won't return the value of wez = CStr(472 / 80 * weight), but if Combobox2.text = "Running " and Combobox3.Text ="5mph" everything will work and the value of wez = CStr(472 / 80 * weight) is assigned to TextBox3.Text. Can someone please help or better still tell me if there's another way of structuring this in order for it to work.

If ComboBox2.Text = "Running" Then
        If ComboBox3.Text = "5mph" Then
            wez = CStr(472 / 80 * weight)
            TextBox3.Text = wez
        ElseIf ComboBox2.Text = "6mph" Then
            wez = CStr(590 / 80 * weight)
            TextBox3.Text = wez
        ElseIf ComboBox2.Text = "7mph" Then
            wez = CStr(679 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = "8mph" Then
            wez = CStr(797 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = "9mph" Then
            wez = CStr(885 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = "10mph" Then
            wez = CStr(944 / 80 * weight)
            TextBox3.Text = wez
        End If

    ElseIf ComboBox2.Text = "Cycling" Then
        If ComboBox3.Text = "<10mph" Then

            wez = CStr(236 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = "10 - 11.9mph" Then
            wez = CStr(354 / 80 * weight)
            TextBox3.Text = wez
        ElseIf ComboBox2.Text = "12 - 13.9mph" Then
            wez = CStr(472 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = "16 - 20mph" Then
            wez = CStr(590 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = "16 - 20mph" Then
            wez = CStr(708 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = ">20mph" Then
            wez = CStr(944 / 80 * weight)
            TextBox3.Text = wez
        End If

    ElseIf ComboBox2.Text = "Swimming" Then

        If ComboBox3.Text = "Freestyle, slow" Then

            wez = CStr(413 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = "Freestyle, fast" Then
            wez = CStr(590 / 80 * weight)
            TextBox3.Text = wez
        ElseIf ComboBox2.Text = "Backstroke" Then
            wez = CStr(413 / 80 * weight)
            TextBox3.Text = wez

        ElseIf ComboBox2.Text = "Breaststroke" Then
            wez = CStr(590 / 80 * weight)
            TextBox3.Text = wez


        ElseIf ComboBox2.Text = "Butterfly" Then
            wez = CStr(649 / 80 * weight)
            TextBox3.Text = wez

        End If

    End If

Aucun commentaire:

Enregistrer un commentaire