Hey I have a program and a sub that restarts the computer but now i want to beable to stop it by pressing F1. please help this newbie
Printable View
Hey I have a program and a sub that restarts the computer but now i want to beable to stop it by pressing F1. please help this newbie
In the Form_QueryUnload event, put this:
Code:Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbAppWindows Then
Cancel = True
Msgbox "The Windows ShutDown has been cancelled.", 16
End If
End Sub
ok but i want it to do that when I press F1
Try this:
Unload Me will trigger the Query_Unload event.Code:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF1) Then Unload Me
End Sub