|
不用类,下面代码全部放到窗体模块
- Public WithEvents cmdUnload As MSForms.CommandButton, WithEvents cmdHide As MSForms.CommandButton, WithEvents cmdSave As MSForms.CommandButton
- Private Sub UserForm_Activate()
- With Controls.Add("Forms.CommandButton.1", "cmdUnload")
- .Caption = "Unload me"
- .Top = 20
- End With
- With Controls.Add("Forms.CommandButton.1", "cmdHide")
- .Caption = "Hide me"
- .Top = 50
- End With
- With Controls.Add("Forms.CommandButton.1", "cmdSave")
- .Caption = "Save"
- .Top = 80
- End With
- Set cmdUnload = Me("cmdUnload")
- Set cmdHide = Me("cmdHide")
- Set cmdSave = Me("cmdSave")
- End Sub
- Private Sub cmdUnload_Click()
- MsgBox "Unload Me" '换成你的处理代码
- End Sub
- Private Sub cmdHide_Click()
- MsgBox "Hide Me" '同上
- End Sub
- Private Sub cmdSave_Click()
- MsgBox "Save" '同上
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|