Results 1 to 3 of 3

Thread: Creating textboxes dynamically durin runtime

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    125

    Creating textboxes dynamically durin runtime

    I need to provide a number of textboxes on a form. The number required is varying, and I don't know how much are needed until runtime. (may be up to 40 or so. ) I could of course put enough onto the form and hide the ones I don't need, but I think it would be better to create them dynamically as soon as I (or my proggie) knows the number. Could somebody help me out on this one?
    I'm thinking along the lines like redimming a control array, but I don't have a clue how to!
    Many thanks in advance.

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Add a textbox, and set its Index property = 0.
    Then try this :

    VB Code:
    1. Dim i As Long
    2. For i = 1 To 10
    3.     Load Text1(i)
    4.     With Text1(i)
    5.         .Visible = True
    6.         .Left = i * 20
    7.         .Text = "Textbox " & i
    8.     End With
    9. Next
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    125

    Thumbs up

    Thanks alot! That's what I meant.
    Live can be so simple....

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