Set array size by a variable

Hi,

i want to size an array according to the value of a variable … and it doesn’t really work …
My code looks like :

dim intLebensdauer as Integer
intLebensdauer=50
dim dblInvest(intLebensdauer) as Double

and i only get the error-message: “The size of an array must be a constant or number”. OK … it’s not constant … but it is a number … ?

What am i doing wrong?
Thanks very much for your assistance

Peter

dim intLebensdauer as Integer intLebensdauer=50 dim dblInvest() as Double ReDim dblInvest(intLebensdauer)

On the same subject matter, to clear the array of all elements:

ReDim dblInvest(-1)