2

This works:

Dim list(9)

But this doesn't:

max_value = 9
Dim list(max_value)

How can I set the limit of this Array Variable using another integer variable (max_value)? I need to do this because the limit of list() will be the maximum value of an auto-incremented value from database.

Or, is it possible to don't set any limit? Or should I just set 999999 as the limit?

3

1 Answer 1

-1

If you create an empty array first, you can then Redim the limit using a variable.

https://www.vbsedit.com/html/5c12ce79-6616-4144-b3b6-4cffe3884dfd.asp

Dim list()
max_value = 9
ReDim list(max_value)

list(0) = "bread"
list(1) = "cereal"
list(2) = "milk"

Msgbox list(1)
Sign up to request clarification or add additional context in comments.

Comments

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.