[SOLVED] VB 6 control array

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

lamstaldy

Thread Starter
Joined
Dec 15, 2001
Messages
113
Is it possible to create a two dimensional control array? I have a grid of command buttons (four across and eight down) that I would like to make into a two dimensional array.
 
Joined
Oct 3, 2002
Messages
2,281
I think it is not possible. All the documentation says object(index) and not object(index1, index2).

But as they say, nothing is impossible. You may be able to find out some indirect workaround somehow. Will have to think hard to be able to do this. But is it worth the effort? You are best judge of how frequently you want to use it.
 
Joined
Oct 9, 2001
Messages
27,087
The only workaround I know of is to write a function to get the object from a single dimension array, by translating 2d coordinates.

Ie, if you KNOW your width is always four, write a function as follows.

Code:
Private Function getCommand(byval X as integer, Byval Y as Integer) as Command
  Set getCommand = CommandArray((y-1) * 4 + x)
End function
Then use that function to get your command object from the array, rather than the array directly.
 

lamstaldy

Thread Starter
Joined
Dec 15, 2001
Messages
113
Thanks for the help. I too could only find info on single dimension control arrays, but I figured it couldn't hurt to ask. I think I'll just create 8 individual control arrays and then pass them to a sub routine as I need them. Nested For loops would have made life easier, but what are you gonna do? Thanks again for the input.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top