Dynamically Dimensioning A VBA Array? -


why unable set size of array based on variable? what's best way around this?

dim numberofzombies integer numberofzombies = 20000 dim zombies(numberofzombies) new zombie 

you can use dynamic array when don't know number of values contain until run-time:

dim zombies() integer redim zombies(numberofzombies) 

or 1 statement if you're creating array that's local procedure:

redim zombies(numberofzombies) integer 

fixed-size arrays require number of elements contained known @ compile-time. why can't use variable set size of array—by definition, values of variable variable , known @ run-time.

you use constant if knew value of variable not going change:

const numberofzombies = 2000 

but there's no way cast between constants , variables. have distinctly different meanings.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -