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.
OK figured out why LisResults was severly spamming creating a huge index. I replaced the code above with the following code: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()
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.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





Reply With Quote