Results 1 to 9 of 9

Thread: KeyAscii Delete???

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Why doesnt the key delete show up
    in keyascii in form_keypress? I
    dont need another way to do it though.

  2. #2
    Guest

    Unhappy

    The only possibility is that <DELETE> is not a keyascii character value, while the other ones like < <Backspace > is. Oh, well, I guess I shouldn't give an alternative...

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    This is indeed pretty strange!

    Code:
    Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyDelete Then
    MsgBox "DELETE!"
    End If
    End Sub
    
    Private Sub Form_Load()
    Me.KeyPreview = True
    End Sub
    The MsgBox does show up when you press the del (.) button on your numerical pad.. strange...

    What's even more strange is that the Form_KeyDown does recognize the delete key...

    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyDelete Then MsgBox "delete"
    End Sub
    
    
    Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyDelete Then MsgBox "delete"
    End Sub
    
    Private Sub Form_Load()
    Me.KeyPreview = True
    End Sub
    By combing the 2 you can capture both keys!

    [Edited by Jop on 10-08-2000 at 06:57 AM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    wow..

    Hmm..

    That is weird..
    Thanks!

  5. #5
    Guest
    The Delete key doesn't have an ASCII value, but it does have a key code. The reason the number pad delete works is that this registers as an ASCII key (the . char), and the system checks this against the numlock state to decided if it's actually the delete call or a . code.

    the key code set in vb allows you to check for every sort of key stroke. The vbKey... prefix matchs the VK_KEY prefix, which stands for "virtual key".

    You can work out the rest

    - gaffa

  6. #6
    Guest
    Jop and Even. Turn your Numlock off and Presto! It works!

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Thats weird!

    why is that?

  8. #8
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Gaffa told us already Evan.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  9. #9
    Guest
    When NumLock is one, we are using the numbers; however when Numlock is off, we use what's written at the bottom of the key.

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