【发布时间】:2014-01-29 13:15:09
【问题描述】:
在 VB.NET 中,我可以遍历字典的键/值对:
Dictionary<string, string> collection = new Dictionary<string, string>();
collection.Add("key1", "value1");
collection.Add("key2", "value2");
foreach (string key in collection.Keys)
{
MessageBox.Show("Key: " + key + ". Value: " + collection[key]);
}
我知道在 VBA 中我可以遍历 Collection 对象的 值:
Dim Col As Collection
Set Col = New Collection
Dim i As Integer
Col.Add "value1", "key1"
Col.Add "value2", "key2"
For i = 1 To Col.Count
MsgBox (Col.Item(i))
Next I
我也知道我使用 Scripting.Dictionary VBA 对象执行此操作,但我想知道这是否可以使用集合。
我可以遍历 VBA 集合中的键/值对吗?
【问题讨论】:
-
据我所知,你不能......如果你想遍历键/值对,你应该使用
Dictionary......
标签: vba excel collections