'Class module class1 code: Option expedition
Private WitHevents MvarcMBTN As CommandButtonPublic Property Set CMBTN (Byval Vdata As Commandbutton) Set mvarcmbtn = vdatand propertyPublic Property Get CMBTN () AS Commandbutton
SET CMBTN = MVARCMBTNEND PROPERTY
Private sub mvarcmbtn_click () msgbox mvarcmbtn.nameend sub 'test form code: Option Explicitdim A () AS Class1
Private submmand1_click () me.controls.remove me.controls ("cmdobj3") 'Delete control End Sub
Private Sub Form_Load () Redim A (5) DIM I AS Integerfor I = 0 to 5Set A (i) = New Class1Set A (i) .cmbtn = me.controls.add ("Vb.commandbutton", "CMDOBJ" & i ) A (i) .cmbtn.visible = truea (i) .cmbtn.top = i * 500Next IEND SUB