我试图在运行时根据记录集的结果创建一个 int 数组。
Do While Not rstSearchResult.EOF
If rstSearchResult(ID) = blah Then
'Add this Id rstSearchResult(ID) to Array
End If
Call rstSearchResult.MoveNext()
Loop
我需要的是相同的结果,因为这会给我
Array(35588, 35589, 35595)
最佳答案
Dim myIntArray() as Integer
Dim intDimension as Integer
intDimension = 0
Do While Not rstSearchResult.EOF
If rstSearchResult(ID) = blah Then
'Add this Id rstSearchResult(ID) to Array
REDIM PRESERVE myIntArray(intDimension)
myIntArray(intDimension) = rstSearchResult(ID)
intDimension = intDimension +1
End If
Call rstSearchResult.MoveNext()
Loop
关于VBA 在运行时添加到数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6125916/