Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


looping unique value form array list

looping unique value form array list

I just have MyArray filled with:
i need to looping a unique items form the array

For example

How to?

RE: looping unique value form array list


What have you tried?

What results did your code yield?

RE: looping unique value form array list

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.

RE: looping unique value form array list

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.

RE: looping unique value form array list

Ted, if you read the thread linked by SaltyTheFrog you'll find that the OP does indeed get their array from a recordset.

It is currently unclear why they don't just do a SELECT DISTINCT

RE: looping unique value form array list

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.

RE: looping unique value form array list

>that did not mention a recordset

Sometimes important to read the whole thread ... winky smile

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.

RE: looping unique value form array list

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.

I also had not thought of using SELECT DISTINCT!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close