Results 1 to 3 of 3

Thread: Creating Runtime Textbox

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    1

    Lightbulb Creating Runtime Textbox

    [SIZE=1][FONT=times new roman][COLOR=blue]
    I would Like to create text box at run time on VB Form ?
    If any one knows then please reply me .

    Thanks in Advance

    Warm Regards
    Suyog
    Cool Regards,
    Suyog

  2. #2
    New Member
    Join Date
    Jan 2002
    Posts
    11
    An easy way is to create a textbox first and hide it (.visible = false) and then show it when you want....but I guess that is not what you are after.

    Another way is to first create a textbox, set the index property to "0" and let the name be the default "text1". Then run the following code under a command button for example :

    Code:
      Load Text1(1)
      Text1(1).Visible = True
      Text1(1).Top = 20
      Text1(1).Left = 20
    This will create an additional textbox for you. When creating an object like this it is by default hidden, so we need to set the visible propery to true and also move it a little bit so it won't be exactly on top of the other one.

    So if you want 10 textboxes run the following code :

    Code:
    Private Sub Command1_Click()
     Dim i As Integer
     For i = 1 To 10
        Load Text1(i)
        Text1(i).Visible = True
        Text1(i).Top = i * 200
        Text1(i).Left = i * 200
     Next i
    End Sub
    good luck
    Last edited by diziz; May 20th, 2003 at 12:36 AM.

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    an alternative is to create it from scratch, without making any controls up front.

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim ctlTxtBox As Control
    3.     Set ctlTxtBox = Controls.Add("VB.TextBox", "ctlTxtBox1", Form1)
    4.     ctlTxtBox.Height = 2000
    5.     ctlTxtBox.Width = 2000
    6.     ctlTxtBox.Visible = True
    7. End Sub
    -= a peet post =-

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