Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dynamic array?
As I searched previous posts, I get the point that only the last
dimension can be redimed. I am wondering what if both dimensions are need to be redimed? I have a 4 dimensional array, and each dimension has a big upperbound. If I define all of them to be fixed expect for the last dimension, it will result in many unnecessary loops. Any suggestions? Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dynamic array?
Only the last dimension can be redimensioned in a dynamic array if you want
to preserve Redim preserve arr(1 to 20, 1 to 30) the data. -- Regards, Tom Ogilvy "lvcha.gouqizi" wrote in message oups.com... As I searched previous posts, I get the point that only the last dimension can be redimed. I am wondering what if both dimensions are need to be redimed? I have a 4 dimensional array, and each dimension has a big upperbound. If I define all of them to be fixed expect for the last dimension, it will result in many unnecessary loops. Any suggestions? Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dynamic
Depending on what you are storing you might be able to replace the 4
dimensions with just one dimension and a user defined type. Then you can just resize the one array and store 4 different variables for each item in the array. Type MyType MyString as string MyInteger as Integer YourInteger as Integer My Double as Double end type sub test() dim MyStuff() as MyType ... 'redim preserve... msgbox Mystuff(1).MyString This might be a bit cryptic if you are not familiar with UDT's. If you need more help just post back. -- HTH... Jim Thomlinson "lvcha.gouqizi" wrote: As I searched previous posts, I get the point that only the last dimension can be redimed. I am wondering what if both dimensions are need to be redimed? I have a 4 dimensional array, and each dimension has a big upperbound. If I define all of them to be fixed expect for the last dimension, it will result in many unnecessary loops. Any suggestions? Thanks. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dynamic array?
Only the last I am afraid. You need to start with the others as big as you
will ever need. Perhaps your loops could exit on an empty element, like this For i = LBound(ary, 1) To UBound(ary, 1) If IsEmpty(ary(i, 1)) Then MsgBox i Exit For End If Next i -- HTH RP (remove nothere from the email address if mailing direct) "lvcha.gouqizi" wrote in message oups.com... As I searched previous posts, I get the point that only the last dimension can be redimed. I am wondering what if both dimensions are need to be redimed? I have a 4 dimensional array, and each dimension has a big upperbound. If I define all of them to be fixed expect for the last dimension, it will result in many unnecessary loops. Any suggestions? Thanks. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dynamic array?
well, thanks. This is really a weak point of VB.
|
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dynamic array?
Maybe you need to redefine you perspective.
Do your really need to redim both dimensions? If the real need is to add rows, then reorient your array to Arr(1 to num columns, 1 to numrows) or use an array of arrays. -- Regards, Tom Ogilvy "lvcha.gouqizi" wrote in message oups.com... well, thanks. This is really a weak point of VB. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dynamic array?
You said you had a four dimensional array, but many people mistakenly call
arr(1 to 20,1 to 4) as a four dimensional array. Also, it is hard to imagine any real use for a 4 dimensional array unless you are willing to do a lot of looping. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Maybe you need to redefine you perspective. Do your really need to redim both dimensions? If the real need is to add rows, then reorient your array to Arr(1 to num columns, 1 to numrows) or use an array of arrays. -- Regards, Tom Ogilvy "lvcha.gouqizi" wrote in message oups.com... well, thanks. This is really a weak point of VB. |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dynamic
thanks. Good idea!
|
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to redim more than one dimension in a multidimensional dyn
I have not done a multi-dimensional array in for ever. I can never keep my
looping straight enough to get back what I want. With UDT's it's easy... Collections can also be very handy. They are more work to impliment but easy to add and remove from. -- HTH... Jim Thomlinson "lvcha.gouqizi" wrote: thanks. Good idea! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ReDim Object array as parameter of Variant array | Excel Programming | |||
Using Application.match against one dimension of a multidimensional array? | Excel Programming | |||
ReDim, Preserve and Multidimensional arrays | Excel Programming | |||
Array transfer - 1 dimension v. 2 dimension | Excel Programming | |||
size of multidimensional dynamic array | Excel Programming |