Difference between revisions of "Using For Next on your own class"
From HashVB
(How to use NewEnum) |
|||
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
− | When doing Object Orientated programming in VB | + | {{VB6}} |
+ | 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: | Normally this is used when wrapping a collection in type specific code. The following snippet exposes the NewEnum method of the wrapped collection: |
Latest revision as of 15:53, 27 September 2006
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.