• Adding a Textbox to a form at run time (Viual Basic 6.0)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Adding a Textbox to a form at run time (Viual Basic 6.0)

    Author
    Topic
    #394758

    Hello,

    Can anyone tell me how to add 1 or more text boxes to a form at runtime?

    This is pretty easy in Office 2000, but I cannot seem to figure it out in VB.

    Thanks,

    Viewing 1 reply thread
    Author
    Replies
    • #726507

      Use the Add method of the Controls collection of the form:

      With Form1.Controls.Add(“VB.TextBox”, “txtText”)
      .Visible = True
      .Left = 300
      .Top = 150
      .Width = 900
      .Height = 180
      End With

      Measurements are in twips; 1 inch = 1440 twips.

      See Add Method (Controls Collection) in the MSDN library for more information.

      • #726576

        Thank you very much. I knew it would be a simple answer, but I just didn’t have any luck finding it.

        Thanks again!

      • #726577

        Thank you very much. I knew it would be a simple answer, but I just didn’t have any luck finding it.

        Thanks again!

    • #726508

      Use the Add method of the Controls collection of the form:

      With Form1.Controls.Add(“VB.TextBox”, “txtText”)
      .Visible = True
      .Left = 300
      .Top = 150
      .Width = 900
      .Height = 180
      End With

      Measurements are in twips; 1 inch = 1440 twips.

      See Add Method (Controls Collection) in the MSDN library for more information.

    Viewing 1 reply thread
    Reply To: Adding a Textbox to a form at run time (Viual Basic 6.0)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: