Results 1 to 5 of 5

Thread: Esc key

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    I need to capture when the user hits ESC. I don't know the ASCII Character Code for it and I'm not sure whether I can capture it like all the other keys or whether I need to use an API.

  2. #2
    Junior Member
    Join Date
    Nov 1999
    Posts
    23

    Post

    The keycode is vbKeyEscape and I believe its value is 27. You can capture this key.

    In the keypress event it would look like if keyascii = vbkeyescape then whatever

    For a command button you just need to set the cancel propery to true.

    Hope this helps!


  3. #3
    Lively Member
    Join Date
    Dec 1999
    Location
    Lindenwold, NJ, USA
    Posts
    67

    Post

    the keycode for esc is 27

  4. #4
    Lively Member
    Join Date
    Dec 1999
    Posts
    106

    Post

    set the form's keypreview property to true

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then
    MsgBox "Escape"
    End If

    End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    thanks, key code 27 is what I needed.

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