Menghitung Rata-Rata untuk program Kelas

Ok di sini adalah apa yang saya punya, tapi aku tidak bisa mendapatkan perhitungan menambahkan kelas dan rata-rata di kotak bagian total.

Private Sub CalcBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcBtn.Click
Dim NumStuTxtBx As Integer
Dim _NOS As Integer 'Number of Students'
Dim _NumOfClasses As Integer 'Number of additional classes'
Dim GrandTotal As Integer
Dim Grades As Double = 0
Dim Computed_Grades As Double = 0
Try
NumStuTxtBx = Integer.Parse(Me.NumStuTxtBx.Text)
_NOS += NumStuTxtBx
CalcBtn.Enabled = False
For a As Integer = 1 To NumStuTxtBx
Grades = CDbl(InputBox("Enter Grades of Students Exams"))
GrandTotal += Grades
Computed_Grades += Grades
AvgTxtBx.Text = CStr(Computed_Grades / _NOS)
AvgStuClsTxtBx.Text = CStr(GrandTotal / _NOS)
Next
NewClsBtn.Enabled = True
Catch ex As Exception
MsgBox("How Many Students are there in this Class?", MsgBoxStyle.OKOnly)
Me.NumStuTxtBx.Text = ""
Me.NumStuTxtBx.Focus()
Return
End Try
Me.NumStuTxtBx.Text = ""
Me.NumStuTxtBx.Focus()
AvgAllClsTxtBx.Text = CStr(GrandTotal / _NumOfClasses)
Return
End Sub

Private Sub NewClsBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewClsBtn.Click
Dim _NOS As Integer 'Number of Students'
Dim _NumOfClasses As Integer 'Number of additional classes'
Dim GrandTotal As Integer
CalcBtn.Enabled = True
NewClsBtn.Enabled = False
_NumOfClasses += 1
NumClsTxtBx.Text = CStr(_NumOfClasses)
AvgAllClsTxtBx.Text = CStr(GrandTotal + _NumOfClasses)
AvgStuClsTxtBx.Text = CStr(GrandTotal / _NOS)
NumStuTxtBx.Text = ""
NumStuTxtBx.Focus()

End Sub

Pengikut


Entri Populer