Justin,
If ListA & ListB are in a dataset I would leave them as DataTable. I would
make sure that each (ListB specifically) has a Primary Key.
You can then use something like:
Dim listA As New DataTable("listA")
listA.PrimaryKey = New DataColumn() {listA.Columns("key")}
Dim listB As New DataTable("listB")
listB.PrimaryKey = New DataColumn() {listB.Columns("key")}
For Each row As DataRow In listA.Rows
If Not listB.Rows.Contains(row!key) Then
' found missing row
End If
Next
The Contains method is overloaded for multiple value keys...
Alternatively you could define a DataView over listB with the fields you are
matching on.
Dim listA As New DataTable("listA")
Dim listB As New DataTable("listB")
Dim viewB As New DataView(listB)
viewB.Sort = "field1, field2, field3"
Dim keys(2) As Object
For Each row As DataRow In listA.Rows
keys(0) = row!field1
keys(1) = row!field2
keys(2) = row!field3
If viewB.Find(keys) = -1 Then
' found missing row
End If
Next
The Find method is overloaded for single value keys...
Hope this helps
Jay
"Justin Emlay" <JE****@NoSpam.com> wrote in message
news:Ox**************@tk2msftngp13.phx.gbl...
I have two lists. These can be in either table form or array. That is, my
data is in a dataset which I can move to an array if need be. ListA is a
master list and it contains all items. ListB contains the same items but
not necessarily all the items. I need to know which items are missing.
I remember messing with a compare array function but now I can't seem to
find it anywhere. Ideas? I would rather NOT loop through each item in
ListA and check to see if it exists in ListB as the lists are HUGE!
I already have
For each item in ListA
For each item in ListB
If not A=B then record data
Next
Next
This takes about 45 minutes to run.
The compare function I remember using did the following:
ArrayA
1
2
3
4
5
ArrayB
2
3
4
Thus ArrayC
1
5
This would still work however a Dataset level function would work better
and moving the Datasets into arrays would take some time as well.
Thanks for any help or insight!