
Help: Dynamically add/remove controls?
I recently had this same question. The easiest way to create controls at
run time is with a control array. Create a control and place it on your
form. Set it's index property to 0. (This tells VB that this part of a
control array even though the array now has only one element.) You can even
set the control's visible property to False.
Let's suppose that the controls you want to create are Command Buttons.
Let's call them cmdTest.
Now, in a procedure in your form you can use the following to create
controls at runtime.
Dim lngIndex as Long
lngIndex = lngIndex + 1
Load cmdTest(lngIndex)
The load command will create a new copy of the control each time you
execute the load command. The index property has to increment so you get
new controls.
Also, don't forget on each new control to set the appropriate properties
such as:
.Top
.Left
.Height
.Width
I hope this helps.
Regards,
Anthony Gatlin
Quote:
> In Visual Basic 5.0, is it possible to add/remove controls (list box,
> radio button, text box, etc.) to a form during run time? Also, can the
> modified form be saved back to the original form or save as a new form?