Results 1 to 5 of 5

Thread: INKEY$ routine

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    3

    Post

    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?

  2. #2
    Addicted Member Razzle's Avatar
    Join Date
    Jan 2000
    Location
    Berlin, Germany
    Posts
    161

    Post

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    3

    Post

    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

    I want the Visual BASIC program to work like this:

    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

  4. #4
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    Why not using the form_keydown event.. eg.
    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
    [This message has been edited by Crazy D (edited 02-07-2000).]

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    3

    Post

    Originally posted by Crazy D:
    Why not using the form_keydown event.. eg.
    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
    [This message has been edited by Crazy D (edited 02-07-2000).]
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width