Discussion:
2dimensional array
(too old to reply)
Netghost
2003-10-01 18:49:00 UTC
Permalink
Hey all

Can someone help me with some code?
More specific on how to built a 2 dimensional array...
Now the code shows something like this :
txt1_1.Enabled = False
txt1_2.Enabled = False
txt1_3.Enabled = False
txt1_4.Enabled = False
txt1_5.Enabled = False
txt1_6.Enabled = False
txt2_1.Enabled = False and so on until txt8_6...

How do i use an array with loop to write this in a few lines of code?
TNX !!

NG.
Martin Trump
2003-10-01 21:45:02 UTC
Permalink
Post by Netghost
Can someone help me with some code?
More specific on how to built a 2 dimensional array...
txt1_1.Enabled = False
txt1_2.Enabled = False
txt1_3.Enabled = False
txt1_4.Enabled = False
txt1_5.Enabled = False
txt1_6.Enabled = False
txt2_1.Enabled = False and so on until txt8_6...
How do i use an array with loop to write this in a few lines of code?
TNX !!
Two possibilities. Note, untested code!

1. Use 8 control arrays instead. Create txt1 and give it an index of 0.
Copy and paste like mad 'till you've got six of them. Similarly for txt2
etc.

Then...

For i=0 to 5
txt1(i).Enabled = False
txt2(i).Enabled = False
'etc.
Next i

2. Simulate a 2-d array of Text Boxes using a 1-d array of them (all you
can have). For an 8 X 6 array (48 of them, txt1(0) - txt1(47)) loop
through them using:-

For i = 0 to 5
For j = 0 to 7
txt1(j + i * 8).Enabled = False.
Next j
Next i

By using txt1(j + i * 8) you can address them as if they were a (j,i)
2-d array.

It's late here, I'm tired, so treat this with caution :-)

Regards
--
Martin Trump
Continue reading on narkive:
Loading...