Results 1 to 3 of 3

Thread: Controls at runtime

  1. #1
    Preethi
    Guest

    Question Controls at runtime

    Hi,
    i want some information about how to create VB Controls at runtime???
    If anybody can explain that with an example(e.g textbox) that would be of great help...

    regards..
    preethi

  2. #2
    Addicted Member Screamager's Avatar
    Join Date
    May 2001
    Location
    Dublin, Ireland
    Posts
    174
    VB Code:
    1. Form1.Controls.Add "VB.TextBox", "txtBox"

    Will add a textbox called txtBox to form1
    Computer /nm./: a device designed to speed and automate errors

  3. #3
    Hyperactive Member
    Join Date
    Feb 2001
    Location
    Belgium/Antwerp
    Posts
    275

    Cool

    Hi,

    This example works with commandbuttons.

    place a button on the form which you name 'cmdKnop' and set the index property to 0.

    Then place the folowwing code behind a commandbutton:

    dim br as integer
    dim j as integer

    br = 1200

    For j = 1 To 10


    Load cmdKnop(j)
    With cmdKnop(j)
    .Visible = True
    .Top = 3480
    .Left = br + 375
    .Width = 375
    .Caption = j
    End With
    br = br + 375

    Next j

    This example uses an array of commandbuttons, if you want to create controls without using an array, it's possible, but it is very difficult (i think) to add events to dynamically added controls without using an array.


    Hope this helps

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