|
-
October 1st, 1999, 06:02 PM
#1
deleting duplicate items from collection?
how to delete or find out duplicate items from a collection. i mean looking for a fast alogorithm which can do this.. or do you know how to catch the error when a duplicate key is added to a collection?
-
October 4th, 1999, 02:02 AM
#2
Re: deleting duplicate items from collection?
VB does not allow duplicates in a collection if you use the Key argument to the Add method of the collection object.
Simply trap the runtime error as in
dim col as new collection
on error goto erradd
col.add Key:=mykey, Item:=myItem
exit sub
erradd:
' handle error here
-
October 4th, 1999, 10:05 AM
#3
Re: deleting duplicate items from collection?
i used this when i put in the key, but when not using the key there would be duplicates in the collection. i guess you got to write your own collection and then check the item you add before putting them in the collection.
-
October 4th, 1999, 12:47 PM
#4
Re: deleting duplicate items from collection?
See http://www.freevbcode.com/ShowCode.Asp?ID=40.
This is a function that evaluates a list (array or collection) and returns false if it does not contain unique values. You can easily modify it to return a collection of unique values instead.
-
October 5th, 1999, 03:34 AM
#5
Re: deleting duplicate items from collection?
you might even be better off by using the
Dictionary object in VB 6!
it's faster and has more methods...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|