Results 1 to 11 of 11

Thread: [RESOLVED] [2005] String Arrary comparison problem

Threaded View

  1. #1

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    Resolved [RESOLVED] [2005] String Arrary comparison problem

    Hey guys,

    I have a problem with the output I am receiving when I attempt to compare two arrays. It seems that output in lisResults just keeps looping even though I have it on a counter. I am going to alter after I post this but I'm not quite sure where I am going wrong here. Anyone spot something that look quite correct?

    The two string arrays I am comparing each have a single character in each index that can be A thru D. If the same index of each array match I would like LisResults to add "Correct" at the same index. This isn't happening though.
    Code:
            Dim ElementGrade As String
            Dim ElementAnswer As String
            Dim i As Integer
    
    
    
            For Each ElementGrade In GradeArray
                For Each ElementAnswer In AnswerArray
                    For i = 0 To 19
                        If GradeArray(CInt(ElementGrade)) = AnswerArray(CInt(ElementAnswer)) Then
                            Display.LisResults.Items.Add("correct")
                        Else
                            Display.LisResults.Items.Add("incorrect")
    
                        End If
                    Next
                Next
            Next
    
            Display.ShowDialog()
    OK figured out why LisResults was severly spamming creating a huge index. I replaced the code above with the following code:

    Code:
            Dim i As Integer
    
    
    
            For i = 0 To 19
                If GradeArray(i) = AnswerArray(i) Then
                    Display.LisResults.Items.Add("correct")
                Else
                    Display.LisResults.Items.Add("incorrect")
                End If
            Next
    My problem now however is that LisResults is constantly adding "correct" to the index because according to the code above the index of GradeArray and AnswerArray are always going to equal each other because they are on the same counter. When I need to do is access and compare the value inside the given index of each array.
    Last edited by Abrium; Apr 20th, 2007 at 05:07 AM. Reason: advancement of the problem
    Abrium
    Asking the beginners questions so you don't have to!
    If by chance hell actually froze over and I some how helped you... Please rate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width