|
-
Oct 22nd, 2002, 02:34 PM
#1
Thread Starter
Frenzied Member
Redim giving error
I am trying to create and resize on the fly a multi dimensional array and im getting an error with the line:
VB Code:
ReDim Preserve ResultsArray(Arrayindex, 4)
Arrayindex contains the number 1 at the time of the error and worked first time thru with Arrayindex set to 0.
I am declaring the array in the globals as Dim ResultsArray()
and then the code at the time im getting the error on is redimensioning as it finds rows. Any ideas anyone? thanx
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 22nd, 2002, 02:38 PM
#2
Search this board long enough and you'll find out that this is one of the biggest things that sticks on our craw. In VB, you can't ReDim the first element of an array... only the second. It sucks I know, that's the way it is.
Would it be possible to switch your elements?
-
Oct 22nd, 2002, 02:43 PM
#3
Thread Starter
Frenzied Member
Techgnome.....brilliant answer....thanks a lot......i knew it but its late and im not thinking straight. Maybe i should start again when ive got a clear head....cheers chap
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 22nd, 2002, 02:46 PM
#4
You can redim the first element, but not the way you want to. The problem is that you can't use Redim Preserve on the first element. However, you can simply Redim the first element. Unfortunately, that will delete all the data from the array. The solution, is to copy the data into a temporary array, redim the array, and copy the data back into the original array. This is slow and cumbersome, but can be split into a function, I would think.
-
Oct 22nd, 2002, 02:59 PM
#5
Thread Starter
Frenzied Member
Yep.....its just another point to tell Microsoft that they have written a load of bo*****. Why cant they write stuff in a logical way????? You just dont think as colums first then rows,....we are all taught in a way like Excel looks......rows first param....then columns second....its a lot harder getting to grips with columns then rows.
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
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
|