Results 1 to 8 of 8

Thread: [RESOLVED] KeyDown event fires twice.

  1. #1

    Thread Starter
    Addicted Member Gymbo's Avatar
    Join Date
    Jan 2006
    Location
    The Oregon Coast
    Posts
    213

    Resolved [RESOLVED] KeyDown event fires twice.

    Hi,

    I'm updating a project (V8xx to V9), the project uses a textbox to accept data from the keyboard. Nothing has changed in any of the events for this textbox.

    The KeyDown event uses both vbKeyBack and vbKeyEscape KeyCodeConstants. With the new version, with no changes in any of the events for this textbox, pressing either key cause the action to be performed twice!

    Anyone have a clue?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: KeyDown event fires twice.

    Quote Originally Posted by Gymbo
    I'm updating a project (V8xx to V9)
    That is VB.NET

    Moved

  3. #3

    Thread Starter
    Addicted Member Gymbo's Avatar
    Join Date
    Jan 2006
    Location
    The Oregon Coast
    Posts
    213

    Re: KeyDown event fires twice.

    Sorry Hack,

    My VB6 project is going from Version 8.0.4 to Version 9.0.0. I had no idea there was a difference between the version information in VB6 and VB.Net, can you move it back?

    Gymbo

  4. #4

    Thread Starter
    Addicted Member Gymbo's Avatar
    Join Date
    Jan 2006
    Location
    The Oregon Coast
    Posts
    213

    Re: KeyDown event fires twice.

    More information.

    Pressing the Backspace key once, removes two characters, from the text box, it should only remove one.

    Pressing the Esc key removes the entire line of text, which is correct, then Windows plays the "Windows XP Ding.wav" which is the Default Beep on my system. If I press the Esc key twice or more in the previous version Windows does not respond with a sound.

    Gymbo

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: KeyDown event fires twice.

    Posting the faulty code would help us determine what is wrong...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Addicted Member Gymbo's Avatar
    Join Date
    Jan 2006
    Location
    The Oregon Coast
    Posts
    213

    Re: KeyDown event fires twice.

    That's the crux of the problem, if I knew the faulty code I'd certainly post it, modify it, or remove it.
    The KeyDown event uses both vbKeyBack and vbKeyEscape KeyCodeConstants. With the new version, with no changes in any of the events for this textbox, pressing either key causes the action to be performed twice!
    I'm planning on changing V9 back to V8.0.4 one procedure at a time until I find the culprit, I'll report here when/if I do.

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: KeyDown event fires twice.

    Perhaps you could post the code in your KeyDown event? Or do you also have codes in your KeyPress and KeyUp events?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8

    Thread Starter
    Addicted Member Gymbo's Avatar
    Join Date
    Jan 2006
    Location
    The Oregon Coast
    Posts
    213

    Re: KeyDown event fires twice.

    dee-u,

    I've tracked it down, it turns out I did add a couple of lines of code to the KeyPress event for that text box, that wasn't need and caused the problems,
    Code:
    '        Case Is < 58, Is > 47   'number key pressed
    '            FlagKey = True
                
            Case Is < 48, Is > 57    'must be between 0 & 9
                KeyAscii = 0
        End Select
       
        If KeyAscii Then keypressed = True
    The commented code is what was added and the FlagKey is set elsewhere.

    I still don't know why it caused the problems.

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