Test+Average

Public Class form1 Dim numofgrades As Integer Dim grade As Integer Dim average As Integer Dim counter As Integer Dim sum As Integer Dim testgrade As Integer Dim counter2 As Integer = 0 Private Sub btnteststaken_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnteststaken.Click numofgrades = Val(txtboxnumberofgrades.Text) counter2 = numofgrades lblcounter.Text = counter2 txtboxnumberofgrades.Text = "" End Sub Private Sub btngrades_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btngrades.Click grade = Val(txtboxnumberofgrades.Text) lstboxtest.Items.Add(Val(txtboxnum.Text)) txtboxnumberofgrades.Text = "" counter2 = counter2 - 1 If counter2 = 0 Then MessageBox.Show("you have entered enough test grades now click average") ElseIf counter2 = -1 Then counter2 = 0 End If lblcounter.Text = counter2 End Sub Private Sub btnaverage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnaverage.Click Do While counter <> numofgrades grade = lstboxtest.Items(counter) sum = sum + grade counter = counter + 1 Loop average = sum / numofgrades lbl.Text = average If average < 59 Then MessageBox.Show("you got a F. +(") ElseIf average < 69 Then MessageBox.Show("You got a D. +|") ElseIf average < 79 Then MessageBox.Show("You Got a C.") ElseIf average < 89 Then MessageBox.Show("You Got a B!") ElseIf average < 100 Then MessageBox.Show("You Got an A! +)") ElseIf average > 100 Then MessageBox.Show("I think that you cheated, Other wise you have an A!") End If End Sub Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click End Sub Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click End End Sub End Class