Reputation: 307
I was wondering if it's possible to set an array's length as a variable value as it would help a lot with my current function.
Essentially what I want to be able to do is:
q = 2
Dim AnswerIDs(q)
However, this results in an error, does anyone know how I could do this?
Upvotes: 1
Views: 987
Reputation: 1174
You can do as follows:
q = 2
Dim AnswerIDs(), i
ReDim AnswerIDs(-1)
i = 0
Do While q > i
ReDim Preserve AnswerIDs(UBound(AnswerIDs) + 1)
AnswerIDs(UBound(AnswerIDs)) = "test"
i = i + 1
Loop
Upvotes: 0