need to exit app when the space bar is pressed
this code whon't work with any keyPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = "189" And Shift = "1" Then End
End Sub
# 1 Re: need to exit app when the space bar is pressed
Because the parameters are Integers, not Strings. Try this:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
' If Shift key pressed...
If Shift And vbShiftMask Then
' ...and Spacebar pressed
If KeyCode = vbKeySpace Then
' End app
Unload Me
End If
End If
End Sub
# 7 Re: need to exit app when the space bar is pressed
i found it
here's the code
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim l As Long
l = GetAsyncKeyState(32) 'ascii code for space
If l <> 0 Then
SendKeys "CAT"
End If
End Sub
you can set the interval of the timer to the time u wish to check for keystrokes
# 8 Re: need to exit app when the space bar is pressed
Have you tried this?
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Then
Unload Me
End If
End Sub
dee-u at 2007-11-11 17:34:40 >
