Results 1 to 7 of 7

Thread: Key Down Problem

  1. #1

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Question Key Down Problem

    For some strange reason i am having problems with the following code:

    Code:
    Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    
            Select Case e.KeyCode
    
                Case Keys.Right
    
                    Call CurrentBlock.Right()
    
                Case Keys.Left
    
                    Call CurrentBlock.Left()
    
                Case Keys.Up
    
                    Call CurrentBlock.Rotate()
    
                Case Keys.Down
    
                    Call CurrentBlock.Down()
    
                Case Else
    
                    Exit Sub
    
            End Select
    
        End Sub
    Its not executing what it should be when the keys are presses. Ive put a breakpoint on it and its not even firing at all when they keys are pressed but i can work out why this is.

    Appreciate any ideas.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Key Down Problem

    try setting form .keypreview to true

  3. #3

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Key Down Problem

    Nope still no luck, Cheers anyways

  4. #4
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Key Down Problem

    Do you have buttons on your form? They will take the focus and block Form Keypresses.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  5. #5

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Key Down Problem

    Ye i have one button. How do i solve this problem if it is the button?

  6. #6

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Key Down Problem

    I have also now added a handler for the buttons key down event however this works for most keys but still not the arrow keys.

    I spose this will do but if anyone knows a way of getting the arrow keys to work that would be great.

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Key Down Problem

    I answered this a few days ago when it was asked by another member. Here is that thread.

    http://www.vbforums.com/showthread.p...ighlight=arrow

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