|
-
Jan 14th, 2000, 01:53 AM
#1
Thread Starter
New Member
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 ?
-
Jan 14th, 2000, 02:02 AM
#2
Junior Member
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
-
Jan 14th, 2000, 02:03 AM
#3
Do This
Code:
Dim Param1 As Integer
Dim Param2 As Integer
Dim Variable() As Integer
Param1 = 1
Param2 = 2
ReDim Variable(Param1, Param2)
------------------
Marty
-
Jan 14th, 2000, 02:04 AM
#4
Hyperactive Member
have you tried:
dim Variable()
redim Variable(param1, param2)?
-
Jan 14th, 2000, 02:12 AM
#5
Hyperactive Member
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. :-)
-
Jan 14th, 2000, 09:18 AM
#6
Lively Member
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?
-
Jan 14th, 2000, 12:44 PM
#7
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).]
-
Jan 16th, 2000, 09:11 AM
#8
Thread Starter
New Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|