Qbasicnews.com

Full Version: Waiting for keypress in vb6
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to wait for a keypress (without getting stuck in an infinite loop of doom).




I basically need INPUT$(1) but in vb6. I don't know where to start so all help will be appreciated.
Look up the GetKeyState API call. Big Grin
nah never I got it. I just had it leave the loop while waiting for a press and come back in when it get's it.
Umm...riiiiiiiiiiiight...next time, can you try cohesive English? Big Grin
Quote:nah never I got it. I just had it leave the loop while waiting for a press and come back in when it get's it.
wt: i tried making sense of you're statement but i cant!
sry I meant soemthing like:

"I figured it out."


=P
I am not sure if this will help but....

This is when the key is pressed.This is the If....Then way.

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyRight Then  '(numpad right)
pac.Left = pac.Left + 48
DrawMap
End If

If KeyCode = vbKeyLeft Then '(numpad left)
pac.Left = pac.Left - 48
DrawMap
End If

If KeyCode = vbKeyUp Then  '(numpad up)
pac.Top = pac.Top - 48
DrawMap
End If

If KeyCode = vbKeyDown Then '(numpad down)
pac.Top = pac.Top + 48
DrawMap

End If
End Sub

This is when the key is not pressed.This the Seclect case.Both work well.

Code:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode

Case vbKeyRight '(numpad right)
pac.Left = pac.Left
Right.Enabled = False

Case vbKeyLeft '(numpad left)
pac.Left = pac.Left
L.Enabled = False

Case vbKeyUp '(numpad up)
pac.Top = pac.Top
Up.Enabled = False

Case vbKeyDown '(numpad down)
pac.Top = pac.Top
Down.Enabled = False

End Select
End Sub


Both of these are for either the arrow keys or the num.pad keys but you can esily use any key you want. To use other keys all you have to do is go into the object browser and look up vbkey and you will get every vbkey in the program.

Hope this helps.
Quote:sry I meant soemthing like:

"I figured it out."


=P

We got the message =P
Sorry :oops: it has been a long weekend