Microsoft Office 2000/Visual Basic Programmer's Guide   

Searching a Dictionary

Strictly speaking, a Dictionary object is not an array, but it's similar. Both are data structures that can store multiple values. The Dictionary object has certain advantages over an array: you can use object programming constructs such as For Each…Next and With…End With statements to work with it, and you don't have to worry about sizing it, as you do an array.

If you use a Dictionary object instead of an array to store a set of data, you can quickly check whether a particular item exists in the dictionary by calling the Exists method of the Dictionary object and passing it the key for the item you want. However, the Exists method doesn't provide any information regarding where the item is within the dictionary or how many times it occurs.

An advantage of using the Exists method with a Dictionary object, rather than using the Filter function with an array, is that the Exists method returns a Boolean value, while the Filter function returns another array. If you don't need to know how many times the search item occurs, using the Dictionary object may simplify your code.