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

Grade report average

$
0
0
I am new to VB 2010 and taking an intro course. I am not sure if this is the place to post so if I am in the wrong place can someone direct me to the right forum. I have an assignment that I need to input the students name and grades in input boxes. It will average the grades and assign a letter grade then post the following format in a listbox.
Student First and lastname, Average: 88, Grade: B

Here is my code. My code does not allow me to enter multiple grades and then average them and place the result in the list box. It allow me to enter one grade and then assign the proper grade but does not show the numerical grade entered. I am using option strict and option explicit on.
Code:

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim sngTotal As Single
        Dim intScores As Integer
        Dim sngAverage As Single
        Dim strNames As String
        Dim strInput As String
        Dim strLetter As String
        Dim intCount As Integer

        sngTotal = 0

        strNames = CStr(InputBox("Enter student name."))
        strInput = InputBox("Enter the value for test score ")
        If Not Integer.TryParse(intScores.ToString, intScores) Then
            Return
        End If

        Do Until intCount > intScores
           
            sngTotal += CSng(strInput)
            intCount += 1
        Loop

        If intScores > 0 Then
            sngAverage = sngTotal / intScores
        End If
        lstGradeReport.Text = sngAverage.ToString

        If sngAverage < 60 Then
            strLetter = "F"
        Else

        End If
        If sngAverage < 70 Then
            strLetter = "D"
        Else

        End If
        If sngAverage < 80 Then
            strLetter = "C"
        Else

        End If
        If sngAverage < 90 Then
            strLetter = "B"
        Else

        End If
        If sngAverage <= 100 Then
            strLetter = "A"
        End If
        lstGradeReport.Items.Add(strNames.ToString & " Average: " & sngAverage.ToString & " Grade: " & strLetter.ToString)
    End Sub

Thanks

Viewing all articles
Browse latest Browse all 27072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>