Click to See Complete Forum and Search --> : control arrays - 2 dimmensional?!


help chris
November 4th, 1999, 08:13 PM
I have a few text boxes, each which belong to their own array. I would like to in essense create a 2 dimmensional array having the text boxes below in a top level array, while each one has another set of text boxes in side. In otherwords I have the following:

txtBox0(0), txtBox0(1), txtBox0(2)
txtBox1(0), txtBox1(1), txtBox1(2)
txtBox2(0), txtBox2(1), txtBox2(2)

and I want:

txtBox(0)(0), txtBox(0)(1), txtBox(0)(2)
txtBox(1)(0), txtBox(1)(1), txtBox(1)(2)
etc.

And if that isn't possible, which I don't think it is, but I'd be happy if someone proved me wrong :), Then how about using what I have first above.

and being able to do some thing like:

dim i as integer, j as integer
for j = 0 to 3 step 1
for i = 0 to 3 step 1
txtBox&j(i).text "blah"
next
next



I know that the txtBox&j won't work, but you get my point I hope. Currently i'm creating the text boxes like this:

Load .txtBox0(.txtBox.uBound + 1)


I just need to basically do that double 'for' loop. Any help is most appriciated.

thanks
chris

Aaron Young
November 4th, 1999, 08:52 PM
What you can do with your existing structure is access the Controls Indirectly via their Name in a String variable using the Controls Collection, the same way you can access Fields in a Recordset by specifying the Field Name instead of the Index Number, eg.

Dim i as Integer, j as Integer
for j = 0 to 3
for i = 0 to 3
me.Controls("txtBox" & j).Item(i).Text = "blah"
next
next





Aaron Young
Analyst Programmer
adyoung@win.bright.net
aarony@redwingsoftware.com

help chris
November 5th, 1999, 09:17 AM
thanks, it worked like a charm. Amazing how simple things can be once you know how to do them. Appriciate it.

chris

November 5th, 1999, 06:48 PM
Indexes for controls don't have to be contiguous, so you could do something like this:


for i = 100 to 300 step 100
for j = n to n1
txtTextBox(i*j) ... yadda
next j
next i




Let me know if it works.

bertovic@pimco.com