Hi Mark,
because the item you add into a collection could be anything, there is no
way to
know its key after it has been added. Look at this code:
dim ss as String
ss = "OhMy"
myCollection.Add ss
at this point, how do you get a key from ss? The VB Collection does not
expose
a method like KeyOfItem(byval index as long). And for my option it is a good
thing. I saw too many programmers making a mess using keys and
collections...
The only way to get an item using the key is to set the key by hand
in the Add method (the 'key' named parameter). Great thing to do, because if
the collection is dynamic the only reasonable way to access its items is the
key, and not the index.
Marco
-----Original Message-----
From: Mark Roworth [mailto:mark.roworth@b...]
Sent: Tuesday, July 30, 2002 5:49 AM
To: professional vb
Subject: [pro_vb] RE: Collections - quick query - either you know it or
you don't
If fact, if I know the index of an item in a collection, how can I find the
key it has been added with?