Results 1 to 5 of 5

Thread: how to use esc to quit

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    I was given this but it doesn't work...????

    Set KeyPreview = true

    Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If (KeyCode = 27) Then Unload Me
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Try.

    1. Setting the KeyPreview property at deisng time.

    2.
    Code:
    Private Sub Form_Load()
      Me.KeyPreview = True
    End Sub
    The other bit looks ok.
    Iain, thats with an i by the way!

  3. #3
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Try this

    Code:
    Private Sub Form_Keydown(KeyAscii As Integer, shift As Integer)
    
    Dim ShiftDown As Boolean
    Dim AltDown As Boolean
    Dim CtrlDown As Boolean
    
        ShiftDown = (shift And vbShiftMask) > 0
        AltDown = (shift And vbAltMask) > 0
        CtrlDown = (shift And vbCtrlMask) > 0
       
        Select Case KeyAscii
            Case vbKeyReturn
                Call cmd1_Click
                Exit Sub
            Case vbKeyEscape
                Unload Me
        End Select
    End Sub
    This space for rent...

  4. #4

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    actually...

    dumb dumb here...I set the property but what I
    forgot was I am playing a wav file while the nag
    does it's nagging...I need to kill the wav because
    it plays till it is finished...

    Call sndPlaySound(ByVal App.Path & "\sitting.wav", SND_SYNC)
    Timer1.Enabled = False
    Unload Me
    Load frmPicDisplay
    frmPicDisplay.Show

    ...would you know how to abort if esc is pressed?


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    Guest
    See your other post regarding Killing WAV files.
    http://forums.vb-world.net/showthrea...threadid=20936

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