Friday, January 8, 2016

How to Know SHIFT/CTRL/ALT was pressed in VBA


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim str As String


Select Case Shift
Case 1
    str = "SHIFT was pressed."
Case 2
    str = "CTRL was pressed."
Case 3
    str = "SHIFT + CTRL was pressed."
Case 4
    str = "ALT was pressed."
Case 5
    str = "ALT + SHIFT was pressed."
Case 6
    str = "ALT + CTRL was pressed."
Case 7
    str = "ALT + SHIFT + CTRL was pressed."
End Select

Me.Label1 = str

End Sub




Download File











No comments :

Post a Comment