Help with Parallel array coding Visual Basic

Here I have the code for this visual basic exercise I am working on. I need help coding the btnDisplay event. I need to store the minimum points I have listed below into a 5-element, one-dimensional integer array named intPoints. Also, for the grades that I have listed below I need a 5-element, one-dimensional string array named strGrades. The arrays should be parallel arrays. The procedure should search the intPoints array for for the number of points entered by the user, and then display the corresponding grade from the strGrades array.

Minimum Points                            Maximum Points                    Grade
               0                                                         299                                        F
           
             300                                                      349                                        D
 
              350                                                    399                                         C
 
             400                                                      449                                        B

             450                                                     500                                         A




Public Class frmMain

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

    Private Sub txtPoints_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPoints.Enter
        txtPoints.SelectAll()
    End Sub

    Private Sub txtPoints_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPoints.KeyPress
        ' accepts only numbers and the Backspace key

        If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
            e.Handled = True
        End If
    End Sub

    Private Sub txtPoints_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPoints.TextChanged
        lblGrade.Text = String.Empty
    End Sub

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








    End Sub

End Class
anault24Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Duy PhamFreelance IT ConsultantCommented:
You can store the Upper-bound Point of Grades into intPoints array, so one way to implement your btnDisplay event could be:

Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
    Dim intPoints As Integer() = New Integer() { 299, 349, 399, 449, 500 }
    Dim strGrades As String() = New String() { "F", "D", "C", "B", "A" }

    Dim enteredPoint As Integer = CInt(txtPoints.Text.Trim)
    Dim idx As Integer = 0
    
    Do While (enteredPoint > intPoints(idx)) And (idx < 4)
        idx = idx + 1
    Loop

    lblGrade.Text = strGrades(idx)
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.