Dim WithEvents ctlAdd As CommandButton  ---窗体级变量
  
Private Sub ctladd_Click()
  MsgBox ("aaa")
End SubPrivate Sub Form_Load()
    Set ctlAdd = Me.Controls.Add("VB.CommandButton", "name")
    With ctlAdd
        .Width = 1245
        .Visible = True
        .Caption = "OK"
    End WithEnd Sub