Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT - How to remove duplicate items from an array?

Status
Not open for further replies.

ftpdoo

Programmer
Aug 9, 2001
202
GB

I have a array in VB called MyArray(50) and it contains the names of towns and some of these names have been entered into the array more than once.

Can someone please help me with the algorithm to remove any duplicate items..

I'm taking these values from a database so if its easier any duplicates could be removed while populating the array..

Many thankx in advance,
Jonathan
 
Thnx,

But I'm even more confused now.. (I'm a newbie to VB)

I want to remove duplicate items from an array called MyArray..

Jonathan
 
Hi,

Well as you can see, its not as simple as it sounds. As MichaelRed writes, it its much more logical to make sure that there are no duplicates BEFORE you put your values into the array.

Sunaj

 
Change your array to a link listed array and point around the dups.

or

after loading your db and by using 2 nested for loops you can check for dups and change them to "", next you need to check for "" in the orginal code and ignore them.

the size of myarray will never change in either case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top