juggernot
Well-known member
- Joined
- Sep 28, 2006
- Messages
- 173
- Programming Experience
- Beginner
I'm trying to make a program where, depending on what keys you press, a button will move a certain direction. I'd like some help using keycodes. I'm just playing around with them, never used them before. So far I can't get them to work.Right now my code looks like this:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.A Then
Varleft = true
ElseIf e.KeyCode = Keys.B Then
Varright = true
End If
Than, in a timer I have the following code:
If Varleft = True Then
Me.Button1.left += -2
ElseIf Varright = True Then
Me.Button1.left += 2
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.A Then
Varleft = true
ElseIf e.KeyCode = Keys.B Then
Varright = true
End If
Than, in a timer I have the following code:
If Varleft = True Then
Me.Button1.left += -2
ElseIf Varright = True Then
Me.Button1.left += 2