example:me.controls.add "VB.Label","lblTest",me
with me!lblTest
  .visible=true
  .caption="test"
end withme is form object.

解决方案 »

  1.   

    Private Sub Command1_Click()
     Dim tt As Label
     Set tt = Me.Controls.Add("VB.Label", "lblTest")
    With tt
      .Visible = True
      .Caption = "test"
    End With
    End Sub
      

  2.   

    Private WithEvents cmd As CommandButtonPrivate Sub cmd_Click()
    MsgBox "clicked"
    End SubPrivate Sub Form_Load()
    Set cmd = Me.Controls.Add("vb.commandbutton", "ctrl")
    With cmd
        .Move 0, 0, ScaleWidth / 5, ScaleHeight / 5
        .Caption = "CommandButton"
        .Visible = True
    End With
    End Sub
      

  3.   

    to : XuyfLy(XuyfLy) 
      因为我每次都会不定量的动态生成,所以预先把控件放上的话,我就不能掌握各控件的Name,不过还是谢谢您^_^