|
-
Aug 21st, 2000, 06:05 PM
#1
Thread Starter
Member
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.
-
Aug 21st, 2000, 07:22 PM
#2
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!
-
Aug 21st, 2000, 07:26 PM
#3
Thread Starter
Member
-
Aug 21st, 2000, 07:43 PM
#4
_______
<?>
[code}
typo error
change
`Select Case KeyCode
to
Select Case KeyCode
[/code]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 21st, 2000, 07:47 PM
#5
Yeah yeah, I'm sorry that I happend to touch the wrong key. But the code is clear enough isn't it?
-
Aug 21st, 2000, 07:50 PM
#6
Thread Starter
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|