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

VS 2010 Checking values in a Do Loop

$
0
0
I have written code for a class. The code works as written, but I am trying to enhance it by verifying the results of an Integer.TryParse. I can't figure out how to do either an If...Then...Else or SelectCase Statement that will work inside the do loop.
Here is my
Code:

      'start loop for an unlimited number of students grades to be input
        Do While MessageBox.Show("Do you need to input grades?", "Grade Input",
                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) =
                        DialogResult.Yes

            'clear any previous results
            lblTotalPoints.Text = ""
            lblGrade.Text = ""

            'get three grades from instructor and add them together
            For intRepetition As Integer = 1 To 3
                Integer.TryParse(InputBox(strPROMPT, strTITLE, ), intReply)

(NOTE: Insert code for determining if intReply falls between 0 and 100, If true, do Next intRepetition;
If false, show a message box)

            Next intRepetition
            lblTotalPoints.Text = intTotalPoints.ToString


            'display the grade based on the cumulative score
            Select Case intTotalPoints
                Case 270 To 300
                    lblGrade.Text = "A"
                Case 240 To 269
                    lblGrade.Text = "B"
                Case 210 To 239
                    lblGrade.Text = "C"
                Case 180 To 209
                    lblGrade.Text = "D"
                Case Else
                    lblGrade.Text = "F"
            End Select
            'zero out the cumulative grade total
            intTotalPoints = 0
        Loop
        'if the user responds "no" to the Grade Input prompt, thank them and end the program
        MessageBox.Show("Thank you for using the Grade Calculator. Please use the Exit button to close the program.", "Exit",
                        MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

I want to verify the intReply value falls between 0 and 100. Thanks in advance for the assist.

Viewing all articles
Browse latest Browse all 27189

Trending Articles



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