CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 1999
    Posts
    14

    control arrays - 2 dimmensional?!

    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


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: control arrays - 2 dimmensional?!

    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
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

  3. #3
    Join Date
    Oct 1999
    Posts
    14

    Re: control arrays - 2 dimmensional?!

    thanks, it worked like a charm. Amazing how simple things can be once you know how to do them. Appriciate it.

    chris


  4. #4
    Guest

    Re: control arrays - 2 dimmensional?!

    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.

    [email protected]






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured