Posts: 2,765
Threads: 138
Joined: Nov 2002
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.
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,279
Threads: 170
Joined: Nov 2003
Look up the GetKeyState API call.
I'd knock on wood, but my desk is particle board.
Posts: 2,765
Threads: 138
Joined: Nov 2002
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.
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,279
Threads: 170
Joined: Nov 2003
Umm...riiiiiiiiiiiight...next time, can you try cohesive English?
I'd knock on wood, but my desk is particle board.
Posts: 4,307
Threads: 63
Joined: May 2003
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!
Posts: 2,765
Threads: 138
Joined: Nov 2002
sry I meant soemthing like:
"I figured it out."
=P
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 40
Threads: 7
Joined: Jul 2004
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
Posts: 4,307
Threads: 63
Joined: May 2003
Quote:sry I meant soemthing like:
"I figured it out."
=P
We got the message =P
Posts: 40
Threads: 7
Joined: Jul 2004
Sorry :oops: it has been a long weekend
ife is better with a buistcuit