Using For Next on your own class

From HashVB
Revision as of 15:53, 27 September 2006 by 87.239.236.150 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 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.