Using For Next on your own class

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

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.