How to implement custom iterable class in VBA

前端 未结 2 834
星月不相逢
星月不相逢 2020-12-05 21:12

I want to add a feature to my classes so I can use them in for-each loops.

I wrote hashmaps, arraylists, queues, sets and so on that I want to iterate over. Now I\'m

相关标签:
2条回答
  • The long and short of it is you can't implement IUnknown. The same goes for Collection. They're both Com objects that are unavailable for extension in VBA. You can create custom collections and do other very cool iterable things though.

    0 讨论(0)
  • 2020-12-05 22:00

    The answer is that it can be done, but it is ugly (requires and IDL, two .BAS modules and two .cls modules (one of which is your Collection Class module). For full information see this link:

    Create Your Own "Super Collections" in VB

    Good luck! It seemed to complicated for what I needed to do, so for now I just iterate over the Collection object enumerator.

    0 讨论(0)
提交回复
热议问题