可以定义一个控件数组,
然后将其添加,用load ocx(i)

解决方案 »

  1.   

    '举例: //在picture1上面添加一个commandbutton
    Private Sub Form_Load()
       Form1.Controls.Add "VB.CommandButton", "cmdOk", Picture1
       With Form1!cmdOk
          .Visible = True
          .Width = 500
          .Caption = "确认(&Y)"
       End With
      

  2.   

    Dim ctlNew As Control
    Dim ctlPrev As ControlPrivate Sub Command1_Click()
    If Not ctlPrev Is Nothing Then
                Controls.Remove ctlPrev
            End If
            Set ctlNew = Form1.Controls.Add("VB.Label", "lblNew")
            Set ctlPrev = ctlNew
            ctlNew.Left = 360
            ctlNew.Top = 360
            ctlNew.AutoSize = True
            ctlNew.Caption = "Label控件"
            ctlNew.Visible = True
    End Sub
      

  3.   

    Form.Controls.Add (ProgID, name, container)
    例:
    Form1.Controls.Add "VB.CommandButton", "Command1"