Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Waiting for keypress in vb6
#1
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.
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#2
Look up the GetKeyState API call. Big Grin
I'd knock on wood, but my desk is particle board.
Reply
#3
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.
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#4
Umm...riiiiiiiiiiiight...next time, can you try cohesive English? Big Grin
I'd knock on wood, but my desk is particle board.
Reply
#5
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!
Reply
#6
sry I meant soemthing like:

"I figured it out."


=P
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#7
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.
ife is better with a buistcuit
Reply
#8
Quote:sry I meant soemthing like:

"I figured it out."


=P

We got the message =P
Reply
#9
Sorry :oops: it has been a long weekend
ife is better with a buistcuit
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)