Results 1 to 3 of 3

Thread: [2008] Wait for keyboard input

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Lancashire UK
    Posts
    375

    [2008] Wait for keyboard input

    Just a quick question, what is the best way to wait for keyboard input in an application.

    For background this is a morse code trainer application and I want it to pause after the morse is sounded to allow the user to input what they think the characters were, once the key has been pressed the next character is then played etc.

    I
    If my post helps , please feel free to rate it

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Wait for keyboard input

    There is no pausing anything. You play a sound, then when the user presses a key you play the next sound. You handle the KeyPress event to detect when the user presses a key.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Fanatic Member
    Join Date
    Feb 2007
    Location
    Eindhoven
    Posts
    828

    Re: [2008] Wait for keyboard input

    this can be a solution

    vb Code:
    1. private str as string = "abc" 'at least two characters in the string
    2. private counter as integer = 0
    3.  
    4. private sub form_load(Sender as object, e as eventArgs) handles Form1.Load
    5.   Sound(str.Chars(counter))
    6.   counter += 1
    7. end sub
    8.  
    9. private textBox1.keyPress(Sender as object, e as ByVal e As System.Windows.Forms.KeyPressEventArgs) handles TextBox1.KeyPress
    10.       sound(str.Cahrs(counter))
    11.       counter += 1
    12.  
    13.   if counter = str.length then
    14.     messageBox.Show("Something")
    15.   ens if
    16. end sub

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