我有一个我正在尝试迭代的集合,我没有问题。我想要实现的是查看集合中的下一个对象,但我找不到任何关于此的内容。
我尝试在 if 语句中使用 (+ 1) 向前看,但这似乎不起作用。
For each a in CollBlank
if CollBlank(a + 1) <> "some value" then
'do code
end if
Next
理想情况下,我希望能够向前看。
Access-vba 和 excel-vba 被标记,因为在 access 和 excel 中都使用了集合,我个人现在在 Access 中使用它,但大多数教程都是通过 Excel 进行的。
最佳答案
而不是使用for each
, 使用 for
使用索引变量循环,例如:
Dim i As Integer
For i = 0 to CollBlank.Count - 2
If CollBlank(i + 1) <> "some value" Then
' Do stuff
End If
Next i
关于excel - 遍历集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57375750/