One way is to use the Dictionary object. Loop through each array element, and use the Dictionary object's "Exists" method to only add unique values to the dictionary. Google will yield many samples.
Create a database table (in memory) of the data as rows (many examples around)
Use a query using FIRST OF in the query will yield only one instance of each number when you loop through the resulting query results.
stromgm
Because I answered the original question on this form that did not mention a recordset.
I assumed he was wanting to find out how to do it with an array obtained by any method.
It should have given him the clue that if he already had it from recordset, then just apply a different "SQL" to the one he has.
Sometimes important to read the whole thread ... ;-)
But if you were looking at it from the point of view of "how to do it with an array obtained by any method" I'm not sure that loading the ADO library just to eliminate duplicates is ideal. The dictionary solution mentioned by guitarzan would be my preferred approach - although I'd be tempted to stick with VB's built in Collection class instead.
Would this depend on the size of the file?
I do use a recordset method I described to extract unique values from a CSV file about 20mb in size.
It only take a few seconds with a recordset. I would think far faster than looping through the records.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.