Can I find out whether the Command1_Click event is trigger by pressing Enter or using the Mouse?
I have tried to put codes in KeyPress, KeyDown and KeyUp, but it seems it is not working?
Would anybody help?
Printable View
Can I find out whether the Command1_Click event is trigger by pressing Enter or using the Mouse?
I have tried to put codes in KeyPress, KeyDown and KeyUp, but it seems it is not working?
Would anybody help?
In command1_Click put
msgbox (" The enter key was not pressed")
end sub
Of course you could store this in a variable instead of using a msgbox.
actually, if you press enter on a command button, it raises the command_click event.
this code works:
if the mouse down event is raised, the command button knows the mouse was usedCode:'general declarations
Option Explicit
Dim boolEnter As Boolean
Private Sub Command1_Click()
If boolEnter = False Then 'check if mouse was used
MsgBox "Mouse used"
Else
MsgBox "Key Used"
End If
boolEnter = True
End Sub
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
boolEnter = False
End Sub
It works, thanks a lot da_silvy
Arc, also thanks for your kindness.
it's a pleasure