comparing values on fields in arraylists
-
thanks but these are arraylists, not arrays so yes the data rows look like this +-----------+ +-----------+ | StrList1 | | StrList2 | +-----------+ +-----------+ | 0 | Jenny | | 0 | Jenny | | 1 | Fred | | 1 | Fred | | 2 | Sony | | 2 | Rudy | | 3 | Marti | | 3 | Marti | | 4 | Rudy | | 4 | Sony | +-----------+ +-----------+ And yes, I want to count the number of times the second value in each row matches, i;e Jenny = Jenny 1, Fred = Fred 2, Sony not = Rudy etc But arraylists are one dimensional Okay, no problem I think because 0 Jenny is still = 0 Jenny; i;e; if I have 0 Jenny and 1 Jenny, it's not a match, its only a match when every thing in the datarow is the same So I tried this with the arraylist, assuming a one dimensional arraylist Dim RowIdx() As Integer = {} For r As Integer = 0 To 9 If arraylist1(r) = arraylist2(r) Then Dim x As Integer = RowIdx.GetUpperBound(0) ReDim RowIdx(x + 1) Dim y As Integer = RowIdx.GetUpperBound(0) RowIdx(y) = i End If Next but I get the same error message I've been getting all lone Operator is not valid for type ( field name) I've had the logic working for arrays, but the program uses arraylists I've tried copying the arraylist to an array, but it doesn't work
Or... Here we have 2 array list ArrList1 -------- arrayA1 * arrayA2 * arrayA3 * arrayA4 * -------- ArrList2 -------- ArrayB1 * arrayB2 * arrayB3 * arrayB4 * -------- *= 1 dimensional array. Lets say you want to compare arrayA2(n).Length with arrayB2(n).Length. But before we compare the values, we need to compare the bounds of arrays. ----------------------- Dim x as integer = ArrList1.GetUpperBound(0), _ y as integer = ArrList2.GetUpperBound(0) if x = y then For i as integer = 0 to x If ArrList1(i).Length = ArrList2(i).Length Then 'put your code here End If Next End If You can't compare "arraylist1(r) = arraylist2(r)" because the value on both side is an array, not property of array. Every array has properties(Length, UpperBound, LowerBound, i;e) I mean you can't compare your gf with your friend's gf, except they properties such as skin color, cute face, height, etc. ;P Here sample code to copy an array from array list to a new array: Dim newarr As Object() = ArrList1(1).Clone Good Luck -- modified at 4:59 Friday 4th August, 2006