Click to See Complete Forum and Search --> : Arrow Key's
insaneman
Jun 2nd, 2002, 07:16 AM
im using this code here:
Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 37 Then
picArrow.Move picArrow.Left - 50
End If
If KeyCode = 39 Then
picArrow.Move picArrow.Left + 50
End If
If KeyCode = 40 Then
picArrow.Move picArrow.Left, picArrow.Top + 50
End If
If KeyCode = 38 Then
picArrow.Move picArrow.Left, picArrow.Top - 50
End If
End Sub
and my picturbox (picArrow) doesnt move at all, ive tryed many different kinds of codes, all i want it to do is move the picArrow, help!
/\/\isanThr0p
Jun 2nd, 2002, 07:18 AM
I am sure it should work like that too some way, but using the getkeystate API will be better anyways so take a look into that...
Interesting
Jun 2nd, 2002, 09:20 AM
if you have a command button or something else that can get 'focus' then it wont work.
if your page is free of command buttons etc and only consists of the form, and your pic then i have no idea.
insaneman
Jun 2nd, 2002, 10:04 AM
this isnt making any sense, i put this code into a new project:
Dim keycode As String
Private Sub form_KeyDown(keycode As Integer, Shift As Integer)
If keycode = 37 Then
MsgBox "you pressed left"
End If
End Sub
and it works perfectly, but when i put it into the project where i want it to be, it doesnt work.
btw, whats the keycode number for enter, escape, and space bar? (where can i get a full list?)
oh and another thing, when i compile the new project which sais "You pressed left" when you press left, and i send it to my friend, he gets the messege when he presses down...
insaneman
Jun 2nd, 2002, 10:12 AM
oh, woops, i made a mistake in that post, that
Dim KeyCode as String
isnt suposed to be there.
everythign works as long as there isnt anything in the form.
insaneman
Jun 2nd, 2002, 11:16 AM
never mind, i got everything to work perfectly. Thansk for the help.
/\/\isanThr0p
Jun 2nd, 2002, 12:17 PM
alright...
by the way for you code
you can post it between code or vbcode tags which will make it much more readable.
insaneman
Jun 2nd, 2002, 01:00 PM
oh right, i dont know how to do that.
/\/\isanThr0p
Jun 2nd, 2002, 01:09 PM
alright put the word
vbcode in those paranthese []
and to end it /vbcode
Pc_Madness
Jun 4th, 2002, 02:38 AM
I just asked the same question in this thread.
http://www.vbforums.com/showthread.php?s=&threadid=176022
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.