Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem with Keydown and e.keyvalue

PCsharkPCshark Member Posts: 1
Something so simple yet it isn't working... in vb.net2005

I have a picturebox called "ball" and I am attempting to move it via arrowkeys. The code that is not working:
----------------------------------------------------
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

If e.KeyValue = 38 Then
Me.Ball.Location -= New System.Drawing.Point(0, 5)
End If

End Sub
-----------------------------------------------------
Note: in this example "38" is the keyvalue for the up arrow key. My goal is to move the ball up 5 spaces on the vb grid

This doesnt have any effect when i test it. Anyone know why? I'd like help if you do.

Comments

  • nhut.nguyennhut.nguyen Member Posts: 12
    This is code correctwith vb.Net 2005

    Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.KeyValue = 38 Then
    Me.ball.Location -= New System.Drawing.Point(0, 5)
    End If
    End Sub


    : Something so simple yet it isn't working... in vb.net2005
    :
    : I have a picturebox called "ball" and I am attempting to move it via arrowkeys. The code that is not working:
    : ----------------------------------------------------
    : Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    :
    : If e.KeyValue = 38 Then
    : Me.Ball.Location -= New System.Drawing.Point(0, 5)
    : End If
    :
    : End Sub
    : -----------------------------------------------------
    : Note: in this example "38" is the keyvalue for the up arrow key. My goal is to move the ball up 5 spaces on the vb grid
    :
    : This doesnt have any effect when i test it. Anyone know why? I'd like help if you do.
    :



Sign In or Register to comment.