Option ExplicitPrivate Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button Then Me.Print "命令按钮被按下" End If End SubPrivate Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button Then Me.Print "命令按钮被释放" End If End Sub
CommandButton 的value属性设为True时是能调用Click事件,但外部通过读它来判断按钮当时是否按下好像不行哦.我用这代码测的Option ExplicitPrivate Sub Command1_Click() Debug.Print "click" End SubPrivate Sub Command2_Click() Command1.Value = False End SubPrivate Sub Timer1_Timer() Caption = Command1.Value End Sub
并且设置style属性为1-Graphical。
用Value属性判断。
If Button Then
Me.Print "命令按钮被按下"
End If
End SubPrivate Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then
Me.Print "命令按钮被释放"
End If
End Sub
Debug.Print "click"
End SubPrivate Sub Command2_Click()
Command1.Value = False
End SubPrivate Sub Timer1_Timer()
Caption = Command1.Value
End Sub
Click
MouseDown
MouseUp