Grade calculator

snash

New member
Joined
May 13, 2016
Messages
1
Programming Experience
Beginner
I have the following code which is supposed to execute on button click. When i run the program, the button is not doing anything. Kindly assist where i got it all wrong
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        If Val(TextBox_vb.Text) <= 100 And Val(TextBox_vb.Text) >= 75 Then


            vb = TextBox_vb.Text("1")
        ElseIf Val(TextBox_vb.Text) <= 74 And Val(TextBox_vb.Text) >= 65 Then
            vb = "2.1"
        ElseIf Val(TextBox_vb.Text) <= 64 And Val(TextBox_vb.Text) >= 60 Then
            vb = "2.2"
        ElseIf Val(TextBox_vb.Text) <= 59 And Val(TextBox_vb.Text) >= 50 Then
            vb = "3"
        ElseIf Val(TextBox_vb.Text) <= 49 And Val(TextBox_vb.Text) >= 0 Then
            vb = "F"
        Else
            MessageBox.Show("Enter valid mark")
        End If




        If Val(TextBox_db.Text) <= 100 And Val(TextBox_db.Text) >= 75 Then


            db = "1"
        ElseIf Val(TextBox_db.Text) <= 74 And Val(TextBox_db.Text) >= 65 Then
            db = "2.1"
        ElseIf Val(TextBox_db.Text) <= 64 And Val(TextBox_db.Text) >= 60 Then
            db = "2.2"
        ElseIf Val(TextBox_db.Text) <= 59 And Val(TextBox_db.Text) >= 50 Then
            db = "3"
        ElseIf Val(TextBox_db.Text) <= 49 And Val(TextBox_db.Text) >= 0 Then
            db = "F"
        Else
            MessageBox.Show("Enter valid mark")




        End If
        If Val(TextBox_dc.Text) <= 100 And Val(TextBox_dc.Text) >= 75 Then


            ob = "1"
        ElseIf Val(TextBox_dc.Text) <= 74 And Val(TextBox_dc.Text) >= 65 Then
            ob = "2.1"
        ElseIf Val(TextBox_dc.Text) <= 64 And Val(TextBox_dc.Text) >= 60 Then
            ob = "2.2"
        ElseIf Val(TextBox_dc.Text) <= 59 And Val(TextBox_dc.Text) >= 50 Then
            ob = "3"
        ElseIf Val(TextBox_dc.Text) <= 49 And Val(TextBox_dc.Text) >= 0 Then
            ob = "F"
        Else
            MessageBox.Show("Enter valid mark")




        End If
        If Val(TextBox_mab.Text) <= 100 And Val(TextBox_mab.Text) >= 75 Then


            copfin = "1"
        ElseIf Val(TextBox_mab.Text) <= 74 And Val(TextBox_mab.Text) >= 65 Then
            copfin = "2.1"
        ElseIf Val(TextBox_mab.Text) <= 64 And Val(TextBox_mab.Text) >= 60 Then
            copfin = "2.2"
        ElseIf Val(TextBox_mab.Text) <= 59 And Val(TextBox_mab.Text) >= 50 Then
            copfin = "3"
        ElseIf Val(TextBox_mab.Text) <= 49 And Val(TextBox_mab.Text) >= 0 Then
            copfin = "F"
        Else
            MessageBox.Show("Enter valid mark")




        End If


        If Val(TextBox_ob.Text) <= 100 And Val(TextBox_ob.Text) >= 75 Then


            datacomms = "1"
        ElseIf Val(TextBox_ob.Text) <= 74 And Val(TextBox_ob.Text) >= 65 Then
            datacomms = "2.1"
        ElseIf Val(TextBox_ob.Text) <= 64 And Val(TextBox_ob.Text) >= 60 Then
            datacomms = "2.2"
        ElseIf Val(TextBox_ob.Text) <= 59 And Val(TextBox_ob.Text) >= 50 Then
            datacomms = "3"
        ElseIf Val(TextBox_ob.Text) <= 49 And Val(TextBox_ob.Text) >= 0 Then
            datacomms = "F"
        Else
            MessageBox.Show("Enter valid mark")




        End If


        If Val(TextBox_cf.Text) <= 100 And Val(TextBox_cf.Text) >= 75 Then


            mab = "1"
        ElseIf Val(TextBox_cf.Text) <= 74 And Val(TextBox_cf.Text) >= 65 Then
            mab = "2.1"
        ElseIf Val(TextBox_cf.Text) <= 64 And Val(TextBox_cf.Text) >= 60 Then
            mab = "2.2"
        ElseIf Val(TextBox_cf.Text) <= 59 And Val(TextBox_cf.Text) >= 50 Then
            mab = "3"
        ElseIf Val(TextBox_cf.Text) <= 49 And Val(TextBox_cf.Text) >= 0 Then
            mab = "F"
        Else
            MessageBox.Show("Enter valid mark")


        End If


    End Sub
 
Last edited by a moderator:
Place a breakpoint on the first line of that code using the F9 key. When you run the project, does that breakpoint get hit? If so then the Button is doing exactly what it's supposed to. In that case, step through the code line by line using the F10 key and see whether it does what you expect it to. You can use the Autos, Locals and Watch windows to determine the state of the application and whether it matches what you expect. If it doesn't then you've found an issue with your code.
 
Back
Top