Results 1 to 4 of 4

Thread: stop sub

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    The Glove state
    Posts
    28

    Question

    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
    Always let the Wookiee Win!

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    The Glove state
    Posts
    28

    Cool ok but

    ok but i want it to do that when I press F1
    Always let the Wookiee Win!

  4. #4
    Guest
    Try this:

    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
    Unload Me will trigger the Query_Unload event.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width