Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27254

Different Grade Book Program

$
0
0
Hey, Have anotehr question about a different code. On this code I keep getting 'Items' is not a member of 'GradeBook.lstGrades'.

Public Class lstGrades

Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click

Dim studentNames(4) As String
Dim Grades(4) As String
Dim Student1Scores(3) As Integer
Dim Student2Scores(3) As Integer
Dim Student3Scores(3) As Integer
Dim Student4Scores(3) As Integer
Dim Student5Scores(3) As Integer
Dim intCount As Integer = 0
Dim StudentAVG(4) As Double
lstGrades.Items.Clear()
Try
studentNames(0) = txtStudent1.Text
studentNames(1) = txtStudent2.Text
studentNames(2) = txtStudent3.Text
studentNames(3) = txtStudent4.Text
studentNames(4) = txtStudent5.Text
Student1Scores(0) = IsValid(CInt(txtOneScore1.Text))
Student1Scores(1) = IsValid(CInt(txtOneScore2.Text))
Student1Scores(2) = IsValid(CInt(txtOneScore3.Text))
Student1Scores(3) = IsValid(CInt(txtOneScore4.Text))
Student2Scores(0) = IsValid(CInt(txtTwoScore1.Text))
Student2Scores(1) = IsValid(CInt(txtTwoScore2.Text))
Student2Scores(2) = IsValid(CInt(txtTwoScore3.Text))
Student2Scores(3) = IsValid(CInt(txtTwoScore4.Text))
Student3Scores(0) = IsValid(CInt(txtThreeScore1.Text))
Student3Scores(1) = IsValid(CInt(txtThreeScore2.Text))
Student3Scores(2) = IsValid(CInt(txtThreeScore3.Text))
Student3Scores(3) = IsValid(CInt(txtThreeScore4.Text))
Student4Scores(0) = IsValid(CInt(txtFourScore1.Text))
Student4Scores(1) = IsValid(CInt(txtFourScore2.Text))
Student4Scores(2) = IsValid(CInt(txtFourScore3.Text))
Student4Scores(3) = IsValid(CInt(txtFourScore4.Text))
Student5Scores(0) = IsValid(CInt(txtFiveScore1.Text))
Student5Scores(1) = IsValid(CInt(txtFiveScore2.Text))
Student5Scores(2) = IsValid(CInt(txtFiveScore3.Text))
Student5Scores(3) = IsValid(CInt(txtFiveScore4.Text))
StudentAVG(0) = getAverage(Student1Scores)
StudentAVG(1) = getAverage(Student2Scores)
StudentAVG(2) = getAverage(Student3Scores)
StudentAVG(3) = getAverage(Student4Scores)
StudentAVG(4) = getAverage(Student5Scores)
For intCount = 0 To 4
If StudentAVG(intCount) >= 90 Then
Grades(intCount) = "A"
ElseIf StudentAVG(intCount) >= 80 Then
Grades(intCount) = "B"
ElseIf StudentAVG(intCount) >= 70 Then
Grades(intCount) = "C"
ElseIf StudentAVG(intCount) >= 60 Then
Grades(intCount) = "D"
ElseIf StudentAVG(intCount) > 0 Then
Grades(intCount) = "F"
End If
Next
For intCount = 0 To 4
lstGrades.Items.Add(" Average Score for " & studentNames(intCount) & " is " & StudentAVG(intCount) & " his Grade is " & Grades(intCount))
Next
Catch
MessageBox.Show("Invalid Input: Enter Values between(0-100)", "Error")
End Try
End Sub

Public Function getAverage(ByVal StudentScores() As Integer)
Dim intTotal, intCount As Integer
Dim dblAverage As Double
For intCount = 0 To 3
intTotal += StudentScores(intCount)
Next
dblAverage = intTotal / 4
Return dblAverage
End Function

Public Function IsValid(ByVal intNum As Integer)
If intNum > 0 And intNum <= 100 Then
Return intNum
Else
Return "Error"
End If
End Function

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

Me.Close()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub txtStudent1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStudent1.TextChanged

End Sub

Private Sub btnClear_Click_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtStudent1.Clear()
txtStudent2.Clear()
txtStudent3.Clear()
txtStudent4.Clear()
txtStudent5.Clear()
txtOneScore1.Clear()
txtOneScore2.Clear()
txtOneScore3.Clear()
txtOneScore4.Clear()
txtTwoScore1.Clear()
txtTwoScore2.Clear()
txtTwoScore3.Clear()
txtTwoScore4.Clear()
txtThreeScore1.Clear()
txtThreeScore2.Clear()
txtThreeScore3.Clear()
txtThreeScore4.Clear()
txtFourScore1.Clear()
txtFourScore2.Clear()
txtFourScore3.Clear()
txtFourScore4.Clear()
txtFiveScore1.Clear()
txtFiveScore2.Clear()
txtFiveScore3.Clear()
txtFiveScore4.Clear()
lstGrades.Items.Clear()
End Sub
End Class

Viewing all articles
Browse latest Browse all 27254

Latest Images

Trending Articles



Latest Images