Normally I use arrays for data processing, however the program I am working on has a nested loop iterating over 2 arrays that can contain 5000+ entries in each. The outside array always has to iterate over every item but the inside array is just looking to see if that array contains the same serial number as the outside array. I'm afraid I'm not being very clear. What I want to do is iterate over one group and for each item in that group (array of serial numbers) check to see if the serial number is in another group.

I tried using collections keyed by serial numbers so that my program would look something like:

for each serial in SerialsIn
sDateOut = DatesOut(serial)
...
further processing
...
next serial



One problem I may have is that not every serial in the SerialsIn collection will be in the DatesOut collection. Besides that though I attempted to retrieve a date by forcing the issue like this:

sDateOut = DatesOut("00012345")



I get an error on the above line "Object is no longer valid" I know that the serial number used is in the collection. Why do I get this error? Is there a better way to process such information? What happens if I use a key on a collection when that key is not in the collection?

-K