问题
I have "ComboBox1" with entries in it. Every time the user selects an entry, the following is triggered:
Private Sub ComboBox1_Change()
call populate(ComboBox1.ListIndex)
End Sub
The function "populate" has the following:
Sub populate(index as integer)
dim arr0, arr1, arr2 ...
arr0 = Array(...)
arr1 = Array(...)
arr2 = Array(...)
Do While x < Application.CountA("arr" + index)
...
Loop
End Sub
I want to make "arr" + index dynamic so it calls the proper array based on the index recevied from the caller function. Can this be done?
回答1:
Sub populate(index as integer)
dim arr(0 to 2)
arr(0) = Array(...)
arr(1) = Array(...)
arr(2) = Array(...)
Do While x < Application.CountA(arr(index))
...
Loop
End Sub
来源:https://stackoverflow.com/questions/31631761/how-to-create-a-dynamic-variable-name-for-an-array