dim txt as controlset txt=controls.add("vb.textbox","txtName")
    txt.visible=true

解决方案 »

  1.   

    有两种方法
    1.Load txt(n)
    Unload txt(n)2.Me.controls.add 
    Control.remove "control Name"两个是匹配使用的
    load 的不能removeadd的,不能 unload
      

  2.   

    以下在form中:
    Option Explicit
    Private WithEvents NewButton As CommandButton
    Private WithEvents NewOption As OptionButton
    Private Sub Command1_Click()
           If NewOption Is Nothing Then
            Set NewOption = _
                Controls.Add("VB.OptionButton", _
                "Option", Me)
            NewOption.Move 3000, 1000, 1000, 300
            NewOption.Caption = "New Option"
            NewOption.Visible = True
        End If
        If NewButton Is Nothing Then
            Set NewButton = _
                Controls.Add("VB.CommandButton", _
                "cmdNew", Me)
            NewButton.Move _
                Command1.Left + Command1.Width + 240, _
                Command1.Top
            NewButton.Caption = "New Button"
            NewButton.Visible = True
        End If
    End Sub
    Private Sub NewButton_Click()
        MsgBox "New button clicked"
    End SubPrivate Sub NewOption_Click()
     MsgBox "New option clicked"
    End Sub