确定对象是否在VBA集合的成员 [英] Determining whether an object is a member of a collection in VBA

查看:485
本文介绍了确定对象是否在VBA集合的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何确定对象是否在VBA集合中的一员?具体而言,我需要找到一个表的定义是否是TableDefs集合中的一员。

How do I determine whether an object is a member of a collection in VBA? Specifically, I need to find out whether a table definition is a member of the TableDefs collection.

推荐答案

您最好的办法是遍历集合的成员,看看有没有比赛,你在找什么。相信我,我不得不这样做了很多次。

Your best bet is to iterate over the members of the collection and see if any match what you are looking for. Trust me I have had to do this many times.

第二个解决方案(这是更坏)是捕捉项目不是在收集错误,然后设置一个标志,表示该项目不存在。

The second solution (which is much worse) is to catch the "Item not in collection" error and then set a flag to say the item does not exist.

这篇关于确定对象是否在VBA集合的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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