1

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?

2 Answers 2

4
q = 2
Dim AnswerIDs()
Redim AnswerIDs(q)
Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

What syntax is that, it certainly isn't vbscript can you even use ReDim AnswerID(-1) like that and what is with i++ this isn't c# or javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.