VB 6 如何使自定义集合类支持 For Each [英] VB 6 How to make Custom Collection Class to support For Each

查看:34
本文介绍了VB 6 如何使自定义集合类支持 For Each的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我参与了一个项目,其客户端前端是用 VB 6 编写的,嗯!我正在尝试开发一个支持 For...Each 语法的自定义集合类.这在VB 6中可能吗?还是我坚持使用 For..Next 和计数器来识别索引.

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.

感谢您的帮助!

推荐答案

关键部分是将这个添加到自定义集合类中...

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

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

并在过程属性中,将过程 ID 设置为 -4,如下所示:

and in the procedure attributes, set the procedure id to -4, like so:

参考:http://www.vb-helper.com/howto_custom_collection_with_for_each.html

这篇关于VB 6 如何使自定义集合类支持 For Each的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆