Results 1 to 4 of 4

Thread: can't create dynamic control array

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904

    can't create dynamic control array

    I'm using VB6 and want to create a set of text boxes dynamically at run-time. I've looked at the "controls.add" method, and I've dug through the help references on control arrays until I'm blue in the face and I've tried everything I can think of. For FORMS, I have no trouble creating dynamic arrays at runtime, but for TextBoxs I just can't get anything to work. Suggestions?

    Thanks for your time.

  2. #2

  3. #3
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Why don't you just put one textbox on the form at design time, initialize its index to 0 to create a control array of 1. Then at run time you can add to the control array with the Load statement.

    Load TextBox(1)
    Load TextBox(2)
    etc.

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  4. #4
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    Yes just make one of the controls at design time set its index property to 0 and then during runtime just load the other controls like this

    VB Code:
    1. dim i as integer
    2. for i = 1 to 20
    3. load txtFunkyStuff(i)
    4. txtfunkystuff(i).left = 1000 + i * 200
    5. txtfunkystuff(i).width = 175
    6. txtfunkystuff.top = 1000
    7. txtfunkystuff.visible = true
    8. next i

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