vba:我如何在集合中搜索? [英] vba: how do i search through a collection?
本文介绍了vba:我如何在集合中搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找集合中的特定元素。
i am looking for a particular element in a collection. how do i know if it exists in the collection?
推荐答案
如果您在将该项目添加到集合时使用了键,看是否引用此键会产生错误:
If you used a key when you added the item to the collection, see if referring to this key gives an error:
on error goto no_item
col.Item "key"
msgbox "Item exists"
exit sub
no_item:
msgbox "Item does not exist"
否则,你必须循环遍历所有项目,看看是否有你需要的。
Otherwise you have to loop through all items to see if there's the one you need.
这篇关于vba:我如何在集合中搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文