This is what I have for my Module :
Module GradeBookModule
Public g_inTotalScore As Integer
Public g_decAverageScore As Decimal
Public g_strLetterScore As String
Public Const g_intMAX_STUDENTS As Integer = 4
Public Const g_intMAX_TEST_SCORES As Integer = 3
Public g_strStudentNames(g_intMAX_STUDENTS) As String
Public g_sngStudent1TestScores(g_intMAX_TEST_SCORES) As Single
Public g_sngStudent2TestScores(g_intMAX_TEST_SCORES) As Single
Public g_sngStudent3TestScores(g_intMAX_TEST_SCORES) As Single
Public g_sngStudent4TestScores(g_intMAX_TEST_SCORES) As Single
Public g_sngStudent5TestScores(g_intMAX_TEST_SCORES) As Single
here is my Main Form:
Public Class MainForm
Private Sub btnEditStudentData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditStudentData.Click
DisplayStudentForm()
End Sub
Private Sub btnCalculateGradeAverages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateGradeAverages.Click
DisplayStudentNames()
DisplayTestAverages()
DisplayLetterScore()
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Sub DisplayStudentForm()
Dim studentForm As New StudentForm
studentForm.ShowDialog()
End Sub
Sub DisplayStudentNames()
lblStudentOne.Text = g_strStudentNames(0)
lblStudentTwo.Text = g_strStudentNames(1)
lblStudentThree.Text = g_strStudentNames(2)
lblStudentFour.Text = g_strStudentNames(3)
lblStudentFive.Text = g_strStudentNames(4)
End Sub
Sub DisplayTestAverages()
lblAverageOne.Text = g_decAverageScore(0)
lblAverageTwo.Text = g_decAverageScore(1)
lblAverageThree.Text = g_decAverageScore(2)
lblAverageFour.Text = g_decAverageScore(3)
lblAverageFive.Text = g_decAverageScore(4)
End Sub
Sub DisplayLetterScore()
lblGradeOne.Text = g_strLetterScore(0)
lblGradeTwo.Text = g_strLetterScore(1)
lblGradeThree.Text = g_strLetterScore(2)
lblGradeFour.Text = g_strLetterScore(3)
End Sub
Public Function LetterGrade() As String
For intCount = 0 To 4
If Average(intCount) >= 90 Then
g_decAverageScore(intCount) = "A"
ElseIf Average(intCount) >= 80 Then
g_decAverageScore(intCount) = "B"
ElseIf Average(intCount) > 70 Then
g_decAverageScore(intCount) = "C"
ElseIf Average(intCount) >= 60 Then
g_decAverageScore(intCount) = "D"
ElseIf Average(intCount) > 0 Then
g_decAverageScore(intCount) = "F"
End If
Next
End Function
Public Function Average() As Integer
Dim intTotal, intCount As Integer
For intCount = 0 To 3
intTotal += (intCount)
Next
g_decAverageScore = CDec(intTotal / 3)
Return CInt(g_decAverageScore)
End Function
End Class
And my Student Form:
Public Class StudentForm
Private Sub StudentForm_Activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated
End Sub
Private Sub btnSaveChanges_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveChanges.Click
StoreStudentNames()
StoreTestScoresStudent1()
StoreTestScoresStudent2()
StoreTestScoresStudent3()
StoreTestScoresStudent4()
StoreTestScoresStudent5()
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Sub StoreStudentNames()
g_strStudentNames(0) = txtStudent1.Text
g_strStudentNames(1) = txtStudent2.Text
g_strStudentNames(2) = txtStudent3.Text
g_strStudentNames(3) = txtStudent4.Text
g_strStudentNames(4) = txtStudent5.Text
End Sub
Sub StoreTestScoresStudent1()
g_sngStudent1TestScores(0) = CSng(txtOneTest1.Text)
g_sngStudent1TestScores(1) = CSng(txtOneTest2.Text)
g_sngStudent1TestScores(2) = CSng(txtOneTest3.Text)
g_sngStudent1TestScores(3) = CSng(txtOneTest4.Text)
End Sub
Sub StoreTestScoresStudent2()
g_sngStudent2TestScores(0) = CSng(txtTwoTest1.Text)
g_sngStudent2TestScores(1) = CSng(txtTwoTest2.Text)
g_sngStudent2TestScores(2) = CSng(txtTwoTest3.Text)
g_sngStudent2TestScores(3) = CSng(txtTwoTest4.Text)
End Sub
Sub StoreTestScoresStudent3()
g_sngStudent3TestScores(0) = CSng(txtThreeTest1.Text)
g_sngStudent3TestScores(1) = CSng(txtThreeTest2.Text)
g_sngStudent3TestScores(2) = CSng(txtThreeTest3.Text)
g_sngStudent3TestScores(3) = CSng(txtThreeTest4.Text)
End Sub
Sub StoreTestScoresStudent4()
g_sngStudent4TestScores(0) = CSng(txtFourTest1.Text)
g_sngStudent4TestScores(1) = CSng(txtFourTest2.Text)
g_sngStudent4TestScores(2) = CSng(txtFourTest3.Text)
g_sngStudent4TestScores(3) = CSng(txtFourTest4.Text)
End Sub
Sub StoreTestScoresStudent5()
g_sngStudent5TestScores(0) = CSng(txtFiveTest1.Text)
g_sngStudent5TestScores(1) = CSng(txtFiveTest2.Text)
g_sngStudent5TestScores(2) = CSng(txtFiveTest3.Text)
g_sngStudent5TestScores(3) = CSng(txtFiveTest4.Text)
End Sub
Private Sub ResetStudentData()
Dim intStudentIndex As Integer = 0
Dim intScoreIndex As Integer = 0
For intStudentIndex = 0 To g_intMAX_STUDENTS
g_strStudentNames(intStudentIndex) = String.Empty
g_strLetterScore(intStudentIndex) = String.Empty
Next
For intScoreIndex = 0 To g_intMAX_TEST_SCORES
g_sngStudent1TestScores(intScoreIndex) = 0.0F
g_sngStudent2TestScores(intScoreIndex) = 0.0F
g_sngStudent3TestScores(intScoreIndex) = 0.0F
g_sngStudent4TestScores(intScoreIndex) = 0.0F
g_sngStudent5TestScores(intScoreIndex) = 0.0F
Next
End Sub
Private Sub btnResetData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResetData.Click
Dim intResult As Integer =
MessageBox.Show("Warning: All previous data will be lost.", "Reset Data",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
If intResult = DialogResult.OK Then
'
ResetStudentData()
txtStudent1.Clear()
txtStudent2.Clear()
txtStudent3.Clear()
txtStudent4.Clear()
txtStudent5.Clear()
txtOneTest1.Clear()
txtOneTest2.Clear()
txtOneTest3.Clear()
txtOneTest4.Clear()
txtTwoTest1.Clear()
txtTwoTest2.Clear()
txtTwoTest3.Clear()
txtTwoTest4.Clear()
txtThreeTest1.Clear()
txtThreeTest2.Clear()
txtThreeTest3.Clear()
txtThreeTest4.Clear()
txtFourTest1.Clear()
txtFourTest2.Clear()
txtFourTest3.Clear()
txtFourTest4.Clear()
txtFiveTest1.Clear()
txtFiveTest2.Clear()
txtFiveTest3.Clear()
txtFiveTest4.Clear()
txtStudent1.Focus()
End If
End Sub
End Class