post #1 of 1
Thread Starter 
ok the purpose is for me to create a 2d array, using the minumum possible points for a specific letter grade (ex 0 to 299 is an F)

i have this working with the minimum points, but i'm beyond confused at this point. the program displays the grade F for points 0 to 299, however, with my code it only works for 0, and not the rest of the range of numbers up to the next letter grade.

doing this with if statements would be simple, but the array thing confuses me. any help is appreciated

Code:
    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        Dim strGradeInfo(,) As String = {{450, "A"}, _
                                         {400, "B"}, _
                                         {350, "C"}, _
                                         {300, "D"}, _
                                         {0, "F"}}
        Dim intPointsEarned As Integer
        Dim intRow As Integer
        Dim strFound As String

        Dim strSearchFor As String
        'Dim intNumRows As Integer
        Integer.TryParse(txtPoints.Text, intPointsEarned)

        ' assign the ID to a variable
        strSearchFor = txtPoints.Text.ToUpper

        ' search for the ID in the first column in the array
        ' continue searching until the ID is found or each 
        ' row has been searched
        intRow = 0
        strFound = "N"

        Do While intRow <= strGradeInfo.GetUpperBound(0) _
        AndAlso strFound = "N"
            If strGradeInfo(intRow, 0) = strSearchFor Then
                strFound = "Y"
            Else
                intRow = intRow + 1
            End If
        Loop

        ' determine whether the ID was found
        If strFound = "Y" Then
            lblGrade.Text = strGradeInfo(intRow, 1)
        Else
            'for errors, mainly for me
            lblGrade.Text = "E" 
        End If
    End Sub
i7-860
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 860 ASUS P7P55D-E LX Sapphire HD 6950 Unlocked 1536 Shaders 1.175v 8GB Samsung MV-3V4G3 
Hard DriveHard DriveOptical DriveOS
2x Spinpoint F3 7200RPM 500GB Samsung 830 SSD Samsung Black 2MB Cache SATA CD/DVD Burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Viewsonic VX2433wm Logitech EX110 Corsair 750TX Cooler Master HAF 922 
MouseAudioOther
Logitech LX7 Xonar Essence STX Denon AH-D2000 
  hide details  
Reply
i7-860
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 860 ASUS P7P55D-E LX Sapphire HD 6950 Unlocked 1536 Shaders 1.175v 8GB Samsung MV-3V4G3 
Hard DriveHard DriveOptical DriveOS
2x Spinpoint F3 7200RPM 500GB Samsung 830 SSD Samsung Black 2MB Cache SATA CD/DVD Burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Viewsonic VX2433wm Logitech EX110 Corsair 750TX Cooler Master HAF 922 
MouseAudioOther
Logitech LX7 Xonar Essence STX Denon AH-D2000 
  hide details  
Reply