![]() |
Finding elements in a collection
Hi
There is nothing like union, intersection, in, not in or any set properties for collections. To test if something is in a collection you must 1. Make sure each element has a unique key when you add it 2. To test if a particular key is in the collection do Err.Clear On error resume next myCollection.Add Item, ItemKey If err.number<0 then msgbox "Sorry, item " & ItemKey & " is in the collection" end if on error goto 0 Unfortunately, this adds the testing item to the collection, so you must be sure it is the same as the original item with that key. If not, you will need two collections - a real one and a testing one! Does anyone out there have a custom Collection Class which has set like properties? regards Paul J Streger wrote: I was told that you can use the 'in' command to see if a particular element exists in a collection, but cannot figure out how to do it, and now I'm skeptical it exists as a function. They described it as: if strElement in colNames then ... but this generates a syntax error, and help has no topics i can find. Can anyone shed light on this? Also does a collection have a function like Join? Thanks. -- ********************* J Streger MS Office Master 2000 ed. MS Project White Belt 2003 |
All times are GMT +1. The time now is 05:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com