Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Public Const VK_CONTROL = &H11 Dim KeyState As Boolean KeyState = GetKeyState(VK_CONTROL) And &HF0000000
用shift就可以了 shift: An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.
shift: An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.
常数 值 描述
vbShiftMask 1 SHIFT 键的位屏蔽。
VbCtrlMask 2 CTRL 键的位屏蔽。
VbAltMask 4 ALT 键的位屏蔽。
Private Sub Command1_KeyUp(KeyCode As Integer, Shift As Integer)
If Shift = 2 Then 'dosth
End Sub
这样就行了
If Shift = 6 Then 'dosth