-
Im not sure if this is the right forum for this but hopefully someone will know how to help. I have two things (for now) a form and a picture box. I want it so that you use the regular arrow keys to control the picture box around the form.
Also, is there a way to have it move smooth like asteriods where it keeps going and gradually slows down (I know thats a game question but its the closest thing I could think of.) Thanx in advance.
-
If you set the KeyPreview property of the Form to True you can use the KeyDown event of the form and check the KeyValue.
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
`Select Case KeyCode
Case vbKeyUp
Picture1.Top = Picture1.Top - 30 'or whatever value you think is appropriate
Case vbKeyDown
Picture1.Top = Picture1.Top + 30
Case vbKeyLeft
Picture1.Left = Picture1.Left - 30
Case vbKeyRight
Picture1.Left = Picture1.Left + 30
End Select
End Sub
Good luck!
-
hmmm
nevermind I missed the first part, Thanx it works perfect! :):):)
[Edited by Crazy VIII on 08-21-2000 at 08:41 PM]
-
<?>
[code}
typo error
change
`Select Case KeyCode
to
Select Case KeyCode
[/code]
-
Yeah yeah, I'm sorry that I happend to touch the wrong key. But the code is clear enough isn't it?
-
Nah it was ok I had missed the line you wrote before the code, I had figured out the typo when it turned red, that was my mistake :D Thanx again! :D