Re: 3 dimensional array

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You contention that "which works fine" is not believeable. You redim your
array with two dimensions and then attempt to address it with 3 dimensions.
Perhaps you posted some earlier code that you have since changed.

In any event, if your array is declared as public, then you would just loop
through it in your other routine, same as you are doing in the code that
works. You can address the limits/bounds of the array with

for i = lbound(ary,1) to ubound(ary,1)
for j = lbound(ary,2) to ubound(ary,2)
' and possibly although unlikely
for k = lbound(ary,3) to ubound(ary,3)
msgbox "ary(" & i & ", " & j & ", " & k & )=" & ary(i,j,k)
next k
next j
next i

--
Regards,
Tom Ogilvy


"gti_jobert" <gti_jobert.22lvzz_1138890601.8005@xxxxxxxxxxxxxxxxxxxxx> wrote
in message news:gti_jobert.22lvzz_1138890601.8005@xxxxxxxxxxxxxxxxxxxxxxxx

Hi again all - having some problems with this! I have the folling loop
to put my values from 9 label boxes on a userform in an array;


Code:
--------------------

Static Counter As Long
Counter = Counter + 1
ReDim Preserve ary(1 To 3, 1 To Counter)

For i = 1 To 3

ary(1, i, Counter) = MachineNumber
ary(2, i, Counter) = Controls("lblDTCode" & i).Caption
ary(3, i, Counter) = Controls("lblDTDuration" & i).Caption

Next i

--------------------


which works fine - my array is filled! But how do I get all the values
out using another button on the same form? Been trying the following
with no joy;


Code:
--------------------


i = 1
j = 0
Do
For p = 1 To 4
ActiveCell.Offset(j, 6) = ary(2, p, i)
ActiveCell.Offset(j, 7) = ary(3, p, i)
Next p
i = i + 1
j = j + 1
Loop Until i = CountPopulatedGrid + 1

--------------------


Any help will be appreciated, might start looking for a new job now.
haha. cheers guys


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile:
http://www.excelforum.com/member.php?action=getinfo&userid=30634
View this thread: http://www.excelforum.com/showthread.php?threadid=507657



.



Relevant Pages

  • Re: Gaussian cluster antenna array data
    ... A gaussian array is aimed towards resonant elements in cluster form. ... but these dimensions have not been ...
    (rec.radio.amateur.antenna)
  • Re: ReDim string in loop
    ... beginning of the loop I redim the array so that I will always have space. ... "Arne Hegefors" skrev: ...
    (microsoft.public.excel.programming)
  • RE: ReDim ArrayXY
    ... You adjust the counter inside the loop - this is generally considered bad ... You want to work with array separate from the loop counter. ... redim v ... myFlaag = False ...
    (microsoft.public.excel.programming)
  • Re: Working with VB6 and Files
    ... > array. ... You want to reduce how often you redim as much as feasibly ... array every iteration of the loop. ... counter for the 2nd dimension, so I don't know why you're not using this ...
    (microsoft.public.vb.general.discussion)
  • RE: Mass Adding Comments
    ... insert code to fill your own array as desired at the beginning of the ... 'Determine number of dimensions in array using Chip Pearson's method ... ' Loop, increasing the dimension index Ndx, until an error occurs. ... 'Exit sub if dimensions do not match ...
    (microsoft.public.excel.programming)