如何为按钮定义个自定义事件
我想让按钮点击后,不发生click事件,而是发生我自定义的事件
[解决办法]
有些超级想不通你的目的是什么?但还是可帮你找个简单办法实现需求:
Class1类代码:
Public Event MyEvent()
Private WithEvents Mycmd As CommandButton
Public Property Set Cmd(vData As CommandButton)
Set Mycmd = vData
End Property
Private Sub Mycmd_Click()
RaiseEvent MyEvent
End Sub
窗体代码:
Private WithEvents clsCmd As Class1
Private Sub clsCmd_MyEvent()
Debug.Print "ok "
End Sub
Private Sub Form_Load()
Set clsCmd = New Class1
Set clsCmd.Cmd = Command1
End Sub