Results 1 to 4 of 4

Thread: With vbKey gone... how do you handle keystrokes?

  1. #1

    Thread Starter
    Junior Member 347Studboy's Avatar
    Join Date
    Apr 2003
    Location
    New Milford, Inthemiddleofnowhere
    Posts
    17

    Question With vbKey gone... how do you handle keystrokes?

    I was just wondering... in VB6, there is a way to handle keystrokes, and it used the vbKey constants. How do you do this kind of thing in VB.Net?
    You might see me on the Neo Productions forums!

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    In the keypress event code for a given control, you'll have something like:

    Code:
                Select Case e.KeyChar
                    Case "+", Microsoft.VisualBasic.ChrW(Keys.Enter)
                        'Some logic
                        e.Handled = True
                    Case "-"
                        'Some other logic
                        e.Handled = True
                End Select

  3. #3

    Thread Starter
    Junior Member 347Studboy's Avatar
    Join Date
    Apr 2003
    Location
    New Milford, Inthemiddleofnowhere
    Posts
    17

    Talking

    Yay, it worked! Thanks for the help!

    One thing though; it didn't work for the main form's KeyPress event... why is that?
    You might see me on the Neo Productions forums!

  4. #4
    Lively Member
    Join Date
    Feb 2003
    Location
    UK
    Posts
    95
    Originally posted by 347Studboy

    One thing though; it didn't work for the main form's KeyPress event... why is that?
    Might be because the keypress was handled by the control with focus rather than the main form itself.

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