Todd Huttenstine wrote:
Hey
How do you test to see if a particular value is in a
collection object?
For example, I have a collection with 5 items in it. The
items in it a "abc", "def", "ghi", "jkl", and "mno".
How can I test to see if the value "jkl" is in this
collection, and return true or false?
Thanks
Todd
If you check the reference to Microsoft Scripting Runtime in the
VB
Editor, you can use a Dictionary Object instead of a Collection and it
gets easy.
Dim dict As New Dictionary
Dim arr, Elem
arr = Array("abc", "def", "ghi", "jkl", "mno")
For Each Elem In arr
dict.Add CStr(Elem), Elem
Next
Debug.Print dict.Exists("jkl") '<--returns True
Debug.Print dict.Exists("xyz") '<--returns False
Alan Beban