In QBASIC, I can use the code:
while inkey$="":wend
to pause the program and let me press a key to continue.
Visual BASIC doesn't have the INKEY$ keyword. How can I simulate INKEY$ in Visual BASIC?
Printable View
In QBASIC, I can use the code:
while inkey$="":wend
to pause the program and let me press a key to continue.
Visual BASIC doesn't have the INKEY$ keyword. How can I simulate INKEY$ in Visual BASIC?
While Getasynckeystate(keycode)<> 0
Dosomething
Wend
GetAsyncKeystate is a api so don't forget to declare it.
keycode must be the key in ASCII
------------------
Razzle
ICQ#: 31429438
I want the Visual BASIC program to work like this:Quote:
Originally posted by Razzle:
While Getasynckeystate(keycode)<> 0
Dosomething
Wend
GetAsyncKeystate is a api so don't forget to declare it.
keycode must be the key in ASCII
start of subway route
print name of first subway station
wait for keypress
print name of next subway station
wait for keypress
print name of next subway station
wait for keypress
print name of next subway station
wait for keypress
print name of next subway station
wait for keypress
until end of route
Why not using the form_keydown event.. eg.
[This message has been edited by Crazy D (edited 02-07-2000).]Code:Dim arrStations(3) As String
Private Sub Form_Load()
arrStations(0) = "Station 1"
arrStations(1) = "Station 2"
arrStations(2) = "Station 3"
arrStations(3) = "Station 4"
End Sub
Private Sub Form_KeyDown(KeyCode as Integer, Shift As Integer)
Static i As Integer
If KeyCode = The_Key_You_Want eg. vbKeySpace Then
lblStation.Caption = arrStations(i)
i = i + 1
If i > 3 Then
MsgBox "You've seen all stations."
Unload Me
End If
End If
End Sub
Crazy D, Putting station names in string array and using a variable to keep track of which station should work but what if I make a mistake while writing the program and I have to fix it? What about creating an array containing station names and type of station such as local, express and terminal station? Jeffrey.Quote:
Originally posted by Crazy D:
Why not using the form_keydown event.. eg.
[This message has been edited by Crazy D (edited 02-07-2000).]Code:Dim arrStations(3) As String
Private Sub Form_Load()
arrStations(0) = "Station 1"
arrStations(1) = "Station 2"
arrStations(2) = "Station 3"
arrStations(3) = "Station 4"
End Sub
Private Sub Form_KeyDown(KeyCode as Integer, Shift As Integer)
Static i As Integer
If KeyCode = The_Key_You_Want eg. vbKeySpace Then
lblStation.Caption = arrStations(i)
i = i + 1
If i > 3 Then
MsgBox "You've seen all stations."
Unload Me
End If
End If
End Sub