|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm new with Visual Basic but i believe this should be simple,
i just can't come up with a VB code that will work. I have two array lists: itemArr: 1,2,3,4,5,6,7,8,9,21,32 IndexArr: 2,3,4,5,6,7,8,9,10,22,33 What would the VB code look like to compare these two arrays and return the first number to a textbox that is in indexArr but not in itemArr? Last edited by edp1959 : April 6th, 2004 at 09:19 AM. Reason: lists were not clear |
|
#2
|
|||
|
|||
|
return first value that in indexArr but not in itemAr?
Here is the code, I haven't try it. but it should work Dim itemArr() as Integer = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 21, 32 } Dim IndexArr() as Integer = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 33 } Dim flag as boolean = false Dim i, j as integer For i = 0 to UBound(itemArr) For j = 0 to UBound(IndexArr) if (itemArr(i) == IndexArr(j)) then flag = true exit for end if Next if (flag == false) return itemArr(i) end if Next wink, Less than $1 / month Web hosting URL |
|
#3
|
|||
|
|||
|
This works exactly what you want......
Dim itemArray() AsInteger = {1, 2, 3, 4, 5, 6, 7, 8, 9, 21, 32} Dim IndexArray() AsInteger = {2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 33} Dim fgEqual AsBoolean = False Dim i, j AsInteger For i = 0 To UBound(IndexArray) For j = 0 To UBound(itemArray) If (itemArray(j) = IndexArray(i)) Then fgEqual = True ExitFor EndIf Next If (fgEqual = False) Then Textbox1.Text = (IndexArray(i).ToString) ExitFor EndIf fgEqual = False Next |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > need help with arrays |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|