如何检查button在vba中单击
我想检查我的用户表单中的button是否被点击,我可以知道我该怎么做? 我的最终目的是获取点击button的次数。 这是沿代码,我input的东西。 感谢您的帮助。
If CommandButton1_Click = True Then x = x + 1 End If
每次你点击一个button,Button_Click()子被调用。 在那里你可以使用一个单元格或全局variables(取决于你想做什么)每次调用该函数时增加。
例如,你可以这样做:
Option Explicit Private Sub CommandButton1_Click() Module1.x = Module1.x + 1 End Sub
在Module1上你有:
Option Explicit Public x As Integer
EDIT1:
当点击第一个button(variablesx)被点击的次数时,我添加了另一个button并显示一个消息框:
Private Sub CommandButton2_Click() MsgBox Module1.x End Sub
你的项目应该像下面这样: