Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB 6 How to make Custom Collection Class to support For Each

Tags:

enumerate

vb6

I've been placed on a project whose client front end is written in VB 6, ack! I'm trying to develop a custom collection class that supports the For...Each syntax. Is this possible in VB 6? Or am I stuck with using the For..Next with counter to identify the index.

Thanks for the help!

like image 468
Chris Avatar asked Apr 12 '11 01:04

Chris


1 Answers

The key part is adding this to the custom collection class...

Public Function NewEnum() As IUnknown
    Set NewEnum = m_Employees.[_NewEnum]
End Function

and in the procedure attributes, set the procedure id to -4, like so: enter image description here

Ref: http://www.vb-helper.com/howto_custom_collection_with_for_each.html

like image 75
Justin Largey Avatar answered Oct 24 '22 20:10

Justin Largey