Using For Next on your own class

From HashVB
Revision as of 22:36, 20 May 2006 by Dee (Talk | contribs)

Jump to: navigation, search
float
 This article is based on Visual Basic 6. Find other Visual Basic 6 articles.

When doing Object Orientated programming in VB (Yeah, you can stop laughing now :o), it is normally useful to be able to use the For Next construct on your own collection classes.

Normally this is used when wrapping a collection in type specific code. The following snippet exposes the NewEnum method of the wrapped collection:

Public Property Get NewEnum() As IUnknown
  Set NewEnum = PrivateCollection.[_NewEnum]
End Property

Unfortunately, this will not work on its own, and you need to go into Procedure attributes (on the tools menu) and set the Procedure ID to -4. Optionally, you can also set it to be hidden.