vb6 can dynamically add a control without control array:
object.add (progid, name, container)
object: necessary. An object expression, its value is "used" in the list of an object.
progid: necessary. A string that identifies the control. Most of the control progid can see objects through the browser to decide. Progid control by the control of the library and class composition. For example, commandbutton control progid is vb.commandbutton. Progid with the object in the browser not the same as shown in the case, visual basic will display a error message including the correct progid.
name: necessary. A string used to identify the members of the collection.
container: Optional. An object reference that specifies the control container. If not specified or null, the default value of controls set their containers. By specifying the parameters, a control can be placed in any existing container control (such as frame control). Users can control or activex document as a container.
For example: (add in picture1 above a commandbutton)
private sub form_load ()
form1.controls.add "vb.commandbutton", "cmdok", picture1
with form1! cmdok
. Visible = true
. Width = 500
. Caption = "confirm (& y)"
Focus: When you add a reference to the need not permit the control to an existing (already deployed good) application, before using the add method to add the controls you have to have the license keyword.
Add no reference in the run-time control
You can also add methods to dynamically add a reference in the project was not the control. ("Not cited" control is not present in the control toolbox). To do this, you must also add keywords to control the license to the licenses collection. The following example be added before adding the control itself, the control of the permit keyword:
private withevents extctl as vbcontrolextender
private sub form_load ()
licenses.add "prjweeks.weeksctl", "xydsfasfjewfe"
set extctl = form1.controls.add ("prjweeks.weeksctl", "ctl1")
extctl.visible = true 'the control is invisible by default.
However, no reference to such a control program of events, you must use withevents keyword to declare a variable as vbcontrolextender target object (as above), and set the object variable to add a reference to the method returns. Then, vbcontrolextender object objectevent events programming the control of the event. Here is a simple example:
dim withevents objext as vbcontrolextender 'statement extender variable
private sub loadcontrol ()
licenses.add "project1.control1", "xydsfasfjewfe"
set objext = controls.add ("project1.control1", "myctl")
objext.visible = true
private sub extobj_objectevent (info as eventinfo)
'Using the select case programming control events.
select case info.name
'Click here to deal with the incident.
'Now show the other case
case else 'unknown event
'Here to deal with unknown events.
Note: not to an inherent control variables assigned to the vbcontrolextender; any such attempt will cause a type mismatch error.
However, you can also use an object variable declared withevents keyword, and set the method returns a reference to the variable, add the control to a dynamic program of events, as shown below.
'Declare an object variable commandbutton.
private withevents cmdobject as commandbutton
private sub form_load ()
set cmdobject = form1.controls.add ("vb.commandbutton", "cmdone")
cmdobject.visible = true
cmdobject.caption = "dynamic commandbutton"
private sub cmdobject_click ()
print "this is a dynamically added control"
If you want to add a user control or any activex control to your form, or to the control must be added to the "tool box", or to control the license tags to the licenses collection. For more information, please refer to the "increasing method (licenses set)."
Note: If you add an activex or user control to your project, but did not use it in the form, you must not select "Project Properties" dialog box "build" tab on the "delete the unused The activex control "option. If your application tries to add the control, then the add method will fail because the necessary information has been discarded.
Remove the control
To remove dynamically add controls, use the "remove" method. Please note that you can only remove those who use the "Add" method to add the control (and use the "load" statement to add the control to compare) the following example to delete a dynamic added controls:
form1.controls.remove "ctl1" 'The name of the control ctl1
Worms and Trojans often stationed where?
News ABOUT Hobby
Corel TEXTURE probe density (b)
Alibaba denies rumors of financial strand breaks from Baidu
MY favorite Graphic
Flv to mpeg converter free
U.S. stocks comment: Sun continued blood loss
CFO Carol Yu, Sohu shares the profits leaving nearly 10 million U.S. dollars
On-site supervision Evaluation 
Open-source Framework For Thinking About 
how to convert M4a to m4r
Easy Games Arcade
Photoshop combat KPT7 (1)
video File converter