In one of my programs, I have to declare a variable as follow :
Dim Variable(Param1, Param2)
But everytime I run my program, I get an error warning me that I must use a constant when declaring an array.
Is there any way around this ?
Printable View
In one of my programs, I have to declare a variable as follow :
Dim Variable(Param1, Param2)
But everytime I run my program, I get an error warning me that I must use a constant when declaring an array.
Is there any way around this ?
I think you have to Dim an array using constants or fixed values. To size it using variables use ReDim e.g.
Function x
Dim arrValues(0,0) as integer
Dim x as integer
Dim y as integer
x=10
y=15
ReDim [with preserve] arrValues(x,y)
End
I've not tried this to check it works, but have a go...
JP
Do This------------------Code:Dim Param1 As Integer
Dim Param2 As Integer
Dim Variable() As Integer
Param1 = 1
Param2 = 2
ReDim Variable(Param1, Param2)
Marty
have you tried:
dim Variable()
redim Variable(param1, param2)?
funny, when I posted no one had replied yet. Looking at the times, we probably all responded at the same time. All with basically the same answer. Ok, maybe it's not that funny but it's friday ok. :-)
Ok, a very similar question! I thaught REDIMing was very slow? Would it not be easier to just dim a variable that would be oversized to handle the variable instead of rediming it?
Rediming may or may not be slow, but allocating a large array takes up memory. Take your pick.
------------------
Marty
[This message has been edited by MartinLiss (edited 01-15-2000).]
Thanks a lot.