Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabling For Each for a Dictionary Object

Status
Not open for further replies.

dalchri

Programmer
Apr 19, 2002
608
US
I know how to enable For Each for a collection object encapsulated in a collection class as follows:
[tt]
Public Property Get NewEnum() As IUnknown
Set NewEnum = col.[_NewEnum]
End Property
[/tt]
However, when I try to do the same for a dictionary object, I get an error message from the compiler, "Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic." The dictionary object that I am referring to is available from the Microsoft Scripting Runtime library (scrrun.dll).

What I am really after is a collection class that will sort by the key values when using For Each regardless of the order the items are added. I am up for an alternative solution in addition to a solution to this specific problem with the dictionary object.

PS: Not using VB.NET yet, still on VB6.

Thanks.
 
Try using For Each vKey in objDictionary.Keys, then use the value of vKey to access the dictionary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top