All pastes #2069180 Raw Edit

Untitled

public text v1 · immutable
#2069180 ·published 2011-05-25 21:47 UTC
rendered paste body
     Private Sub btnAssign_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAssign.Click

        ' declare constants and variables
        Const strMSG As String = "Enter score: "
        Dim intTotalPoints As Integer
        Dim intScore As Integer
        Dim strInputScore As String


        ' use an input box box to fetch input for the three test scores
        For intCount As Integer = 1 To 3
            strInputScore = InputBox(strMSG, "Grade Calculator")
            Integer.TryParse(strInputScore, intScore)
            intTotalPoints += intScore
        Next intCount

        ' As long as the total points is not greater than 300
        If (intTotalPoints <= 300) Then
            Dim strLetterGrade As String
            ' use the total score to assign a grade
            Select Case intTotalPoints
                Case 270 To 300
                    strLetterGrade = "A"
                Case 240 To 269
                    strLetterGrade = "B"
                Case 210 To 239
                    strLetterGrade = "C"
                Case 180 To 209
                    strLetterGrade = "D"
                Case 0 To 180
                    strLetterGrade = "F"
            End Select

            ' output the total points and the letter grade
            lblTotalPoints.Text = intTotalPoints.ToString
            lblGrade.Text = strLetterGrade
        Else
            MessageBox.Show("Error: The total points must be less than 300.", "Excessive Points Warning!", _
                           MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            intTotalPoints = 0
        End If

    End Sub