How can you start a program with an key?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hanver
    New Member
    • Oct 2006
    • 6

    #1

    How can you start a program with an key?

    If you start a program u wrote, u can activate by pressing a start button u made and stop it with a stop button.
    but how can you start it by ex. pressing F11 and stopping it by pressing F12?
    Hope some can help

    greets
    hanver
  • albertw
    Contributor
    • Oct 2006
    • 267

    #2
    Originally posted by hanver
    If you start a program u wrote, u can activate by pressing a start button u made and stop it with a stop button.
    but how can you start it by ex. pressing F11 and stopping it by pressing F12?
    Hope some can help

    greets
    hanver

    use the method keydown within your form
    eg:

    Private Sub frmMain_KeyDown (KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
    Case Is = vbKeyF11
    put your code here ...............
    Case Is = vbKeyF12
    put your code here ...............
    End Select
    End Sub

    Comment

    • hanver
      New Member
      • Oct 2006
      • 6

      #3
      thx, I'm going to test in now

      Comment

      • hanver
        New Member
        • Oct 2006
        • 6

        #4
        Private Sub frmMain_KeyDown (KeyCode As Integer, Shift As Integer)

        is this you form where your labels and so on are in?
        because the code doesn't work for me

        Comment

        • albertw
          Contributor
          • Oct 2006
          • 267

          #5
          Originally posted by hanver
          Private Sub frmMain_KeyDown (KeyCode As Integer, Shift As Integer)

          is this you form where your labels and so on are in?
          because the code doesn't work for me
          yep that's the one
          note that you need to have a keydown event when your form has focus !, otherwise select the sub ..keydown from the object which has focus.

          Comment

          Working...