1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

[SOLVED] VB 6 control array

Discussion in 'Software Development' started by lamstaldy, Oct 16, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. lamstaldy

    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.
     
  2. AbvAvgUser

    AbvAvgUser

    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.
     
  3. Gibble

    Gibble

    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.
     
  4. lamstaldy

    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.
     
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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/172398

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice