Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multi-dimensional arrays


Hello,

I have a userform with 9 labels;

-lblA1, lblA2, lblA3
-lblB1, lblB2, lblB3
-lblC1, lblC2, lblC3

and on the same userform i have a button, when the user clicks it
want all the values from the labels to be stored into an array NB. th
user may press the button max times 6 - thus everytime the button i
pressed 9 variables are stored into the array and if the button clicke
6 times then 54 would be stored.

Any Ideas? I'm not so good on 2d arrays :eek

--
gti_jober
-----------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...fo&userid=3063
View this thread: http://www.excelforum.com/showthread.php?threadid=50728

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Multi-dimensional arrays

Something like this

Dim ary()

Private Sub CommandButton1_Click()
Static counter As Long

counter = counter + 1
ReDim Preserve ary(1 To 2, 1 To counter)
ary(1, counter) = lblA1.Caption
ary(2, counter) = lblA2.caption
ary(3, counter) = lblA3.caption
ary(4, counter) = lblB1.Caption
ary(5, counter) = lblB2.caption
ary(6, counter) = lblB3.caption
ary(7, counter) = lblC1.Caption
ary(8, counter) = lblC2.caption
ary(9, counter) = lblC3.caption

End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"gti_jobert" wrote
in message ...

Hello,

I have a userform with 9 labels;

-lblA1, lblA2, lblA3
-lblB1, lblB2, lblB3
-lblC1, lblC2, lblC3

and on the same userform i have a button, when the user clicks it i
want all the values from the labels to be stored into an array NB. the
user may press the button max times 6 - thus everytime the button is
pressed 9 variables are stored into the array and if the button clicked
6 times then 54 would be stored.

Any Ideas? I'm not so good on 2d arrays


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile:

http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=507286



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Multi-dimensional arrays

Any Ideas? I'm not so good on 2d arrays

I believe a 3D array would be the most appropriate structure.
I took the liberty of modifying Bob's code to the following,

Dim ary()

Private Sub CommandButton1_Click()
Static Counter As Long
Counter = Counter + 1
ReDim Preserve ary(1 To 3, 1 To 3, 1 To Counter)
ary(1, 1, Counter) = lblA1.Caption
ary(2, 1, Counter) = lblA2.Caption
ary(3, 1, Counter) = lblA3.Caption
ary(1, 2, Counter) = lblB1.Caption
ary(2, 2, Counter) = lblB2.Caption
ary(3, 2, Counter) = lblB3.Caption
ary(1, 3, Counter) = lblC1.Caption
ary(2, 3, Counter) = lblC2.Caption
ary(3, 3, Counter) = lblC3.Caption
End Sub


Regards,
Vic Eldridge






"gti_jobert" wrote:


Hello,

I have a userform with 9 labels;

-lblA1, lblA2, lblA3
-lblB1, lblB2, lblB3
-lblC1, lblC2, lblC3

and on the same userform i have a button, when the user clicks it i
want all the values from the labels to be stored into an array NB. the
user may press the button max times 6 - thus everytime the button is
pressed 9 variables are stored into the array and if the button clicked
6 times then 54 would be stored.

Any Ideas? I'm not so good on 2d arrays


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=507286


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Multi-dimensional arrays

I would agree with you if you had loops per dimension, but as one dimension
is loaded item by item, I cannot see the point of adding a further dimension
that just complicates the code and makes maintenance more difficult.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Vic Eldridge" wrote in message
...
Any Ideas? I'm not so good on 2d arrays


I believe a 3D array would be the most appropriate structure.
I took the liberty of modifying Bob's code to the following,

Dim ary()

Private Sub CommandButton1_Click()
Static Counter As Long
Counter = Counter + 1
ReDim Preserve ary(1 To 3, 1 To 3, 1 To Counter)
ary(1, 1, Counter) = lblA1.Caption
ary(2, 1, Counter) = lblA2.Caption
ary(3, 1, Counter) = lblA3.Caption
ary(1, 2, Counter) = lblB1.Caption
ary(2, 2, Counter) = lblB2.Caption
ary(3, 2, Counter) = lblB3.Caption
ary(1, 3, Counter) = lblC1.Caption
ary(2, 3, Counter) = lblC2.Caption
ary(3, 3, Counter) = lblC3.Caption
End Sub


Regards,
Vic Eldridge






"gti_jobert" wrote:


Hello,

I have a userform with 9 labels;

-lblA1, lblA2, lblA3
-lblB1, lblB2, lblB3
-lblC1, lblC2, lblC3

and on the same userform i have a button, when the user clicks it i
want all the values from the labels to be stored into an array NB. the
user may press the button max times 6 - thus everytime the button is
pressed 9 variables are stored into the array and if the button clicked
6 times then 54 would be stored.

Any Ideas? I'm not so good on 2d arrays


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile:

http://www.excelforum.com/member.php...o&userid=30634
View this thread:

http://www.excelforum.com/showthread...hreadid=507286




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multi-dimensional arrays


Thanks guys for your help - it has been very helpful! I am using the 2-d
array as suggested at the moment, but may switch to the 3-d as i am
going to loop my values into it!


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=507286



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Multi-dimensional arrays

Hi Bob,

Perhaps I read too much into the OP's label naming convention.

-lblA1, lblA2, lblA3
-lblB1, lblB2, lblB3
-lblC1, lblC2, lblC3


I looked at that and saw 3 A's, 3 B's & 3 C's.
I also saw 3 1's, 3 2's & 3 3's.
There were also the 6 separate instances of the button being clicked.
A 3D array would allow the OP to easily loop through any of the above groups.

If the OP had named his labels lbl1 - lbl9 , I would have chosen a 2D array.
I think I should stop trying to read between the lines :-)


Regards,
Vic Eldridge


"Bob Phillips" wrote:

I would agree with you if you had loops per dimension, but as one dimension
is loaded item by item, I cannot see the point of adding a further dimension
that just complicates the code and makes maintenance more difficult.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Vic Eldridge" wrote in message
...
Any Ideas? I'm not so good on 2d arrays


I believe a 3D array would be the most appropriate structure.
I took the liberty of modifying Bob's code to the following,

Dim ary()

Private Sub CommandButton1_Click()
Static Counter As Long
Counter = Counter + 1
ReDim Preserve ary(1 To 3, 1 To 3, 1 To Counter)
ary(1, 1, Counter) = lblA1.Caption
ary(2, 1, Counter) = lblA2.Caption
ary(3, 1, Counter) = lblA3.Caption
ary(1, 2, Counter) = lblB1.Caption
ary(2, 2, Counter) = lblB2.Caption
ary(3, 2, Counter) = lblB3.Caption
ary(1, 3, Counter) = lblC1.Caption
ary(2, 3, Counter) = lblC2.Caption
ary(3, 3, Counter) = lblC3.Caption
End Sub


Regards,
Vic Eldridge






"gti_jobert" wrote:


Hello,

I have a userform with 9 labels;

-lblA1, lblA2, lblA3
-lblB1, lblB2, lblB3
-lblC1, lblC2, lblC3

and on the same userform i have a button, when the user clicks it i
want all the values from the labels to be stored into an array NB. the
user may press the button max times 6 - thus everytime the button is
pressed 9 variables are stored into the array and if the button clicked
6 times then 54 would be stored.

Any Ideas? I'm not so good on 2d arrays


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile:

http://www.excelforum.com/member.php...o&userid=30634
View this thread:

http://www.excelforum.com/showthread...hreadid=507286





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multi-dimensional arrays


Dim ary()

Private Sub CommandButton1_Click()
Static counter As Long

counter = counter + 1
ReDim Preserve ary(1 To 2, 1 To counter)
ary(1, counter) = lblA1.Caption
ary(2, counter) = lblA2.caption
ary(3, counter) = lblA3.caption
ary(4, counter) = lblB1.Caption
ary(5, counter) = lblB2.caption
ary(6, counter) = lblB3.caption
ary(7, counter) = lblC1.Caption
ary(8, counter) = lblC2.caption
ary(9, counter) = lblC3.caption

End Sub


Hi Bob,

Shouldn't
ReDim Preserve ary(*1 To 2*, 1 To counter) be
ReDim Preserve ary(*1 To 9*, 1 To counter)?

Davidm


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=507286

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Dimensional Lookup coolkat Excel Discussion (Misc queries) 1 June 14th 11 11:48 PM
Conditional IF formula using multi-dimensional arrays iperlovsky Excel Worksheet Functions 2 April 13th 10 05:15 PM
two dimensional arrays Dave Breitenbach Excel Worksheet Functions 4 September 19th 07 09:12 PM
Declaring 2 dimensional arrays Dan[_49_] Excel Programming 4 November 17th 05 08:36 PM
Multi-Dimensional Array Let & Get Trip[_3_] Excel Programming 0 September 21st 05 08:41 PM


All times are GMT +1. The time now is 03:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"