0

Hi Guys, i am working on a project for class that inputs 6 grades into text boxes and gives the numerical average and the letter grade. i am still not quite grasping Visual Studio so please bare with me. I am confused on how to get the grades to post to the respective labels for grade Average and Letter Grade. Any help will be most appreciated. I have looked at a few of the posts on here with the same subject but can't really follow them.

I am really stuck on the syntax i understand how the logic works but the syntax gets the best of me. Here's what i have so far!!!

Option Explicit On
Option Strict Off
Option Infer On




Partial Class _Default
    Inherits System.Web.UI.Page

    Private testCore1 As Decimal
    Private testCore2 As Decimal
    Private testCore3 As Decimal
    Private testCore4 As Decimal
    Private testCore5 As Decimal
    Private testCore6 As Decimal
    Private AverageScore As Decimal
   

    Protected Sub Txt1_TextChanged(sender As Object, e As System.EventArgs) Handles Txt1.TextChanged
        'Dim AverageScore As Decimal
        If (Txt1.ToString < "0" OrElse Txt1.ToString > "9") AndAlso Txt1.ToString <> "." _
          AndAlso Txt1.ToString <> ControlChars.Back Then

            'LblResult.Text = Average.ToString
        End If
    End Sub

    Protected Sub BtnClear_Click(sender As Object, e As System.EventArgs) Handles BtnClear.Click
        Txt1.Text = String.Empty
        Txt2.Text = String.Empty
        Txt3.Text = String.Empty
        Txt4.Text = String.Empty
        Txt5.Text = String.Empty
        Txt6.Text = String.Empty
        LblResult.Text = String.Empty
    End Sub

    Protected Sub BtnSubmit_Click(sender As Object, e As System.EventArgs) Handles BtnSubmit.Click 
        Call Calculations()
        LblResult.Text = AverageScore.ToString




    End Sub
    
    Public Sub Calculations()
        Dim AverageScore As Decimal
        Dim strLetterGrade As String




        Decimal.TryParse(Txt1.Text, testCore1)
        Decimal.TryParse(Txt2.Text, testCore2)
        Decimal.TryParse(Txt3.Text, testCore3)
        Decimal.TryParse(Txt4.Text, testCore4)
        Decimal.TryParse(Txt5.Text, testCore5)
        Decimal.TryParse(Txt6.Text, testCore6)
        Decimal.TryParse(LblResult.Text, AverageScore)


        AverageScore = (testCore1 + testCore2 + testCore3 + testCore4 + testCore5 + testCore6) / 6
        If AverageScore >= 89.5 Then

            strLetterGrade = "A"

        ElseIf AverageScore >= 79.5 Then

            strLetterGrade = "B"

        ElseIf AverageScore >= 69.5 Then

            strLetterGrade = "C"

        ElseIf AverageScore >= 59.5 Then

            strLetterGrade = "D"

        Else

            strLetterGrade = "F"

        End If

        Return
        
        ' LblResult.Text = AverageScore.ToString
        lblLetterGrade.Text = strLetterGrade.ToString
    End Sub
End Class
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Consider
0

Are you getting any type of error messages? What is being populated in the labels?

If there is a problem with syntax, Visual Studio will highlight it and give you some kind of clue on where you went wrong.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.