how to set Hot key in VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nivaz
    New Member
    • Feb 2008
    • 17

    #1

    how to set Hot key in VB6

    hai friends, i really want to how to set a hot key for an event.
    FOR EX: if i press the key "X" then the second form have to open.
    So far u all helped in several problem. so now also i am hoping you all will help me to finish this thing.
    Thank u all
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to handle the KeyPress and KeyDown events.

    Comment

    • nivaz
      New Member
      • Feb 2008
      • 17

      #3
      Originally posted by debasisdas
      You need to handle the KeyPress and KeyDown events.
      Is there any coding available for those kind of things?

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        Write the code in "Form_KeyUp " event

        Regards
        Veena

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Try to handle the KeyAscii in the Key press event of the control.

          Comment

          • gobblegob
            New Member
            • Dec 2007
            • 133

            #6
            Originally posted by nivaz
            hai friends, i really want to how to set a hot key for an event.
            FOR EX: if i press the key "X" then the second form have to open.
            So far u all helped in several problem. so now also i am hoping you all will help me to finish this thing.
            Thank u all

            Hi nivaz this is what you need to do

            1. on form1 set property KeyPreview = TRUE
            2. add another form to the project ( Form2 )
            3. add this code to form1

            Code:
            Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
               If KeyCode = vbKeyX Then
                   Form2.Show
                      End If
            End Sub
            Hope this answers your question.
            GobbleGob

            Comment

            • nivaz
              New Member
              • Feb 2008
              • 17

              #7
              Originally posted by gobblegob
              Hi nivaz this is what you need to do

              1. on form1 set property KeyPreview = TRUE
              2. add another form to the project ( Form2 )
              3. add this code to form1

              Code:
              Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
                 If KeyCode = vbKeyX Then
                     Form2.Show
                        End If
              End Sub
              Hope this answers your question.
              GobbleGob

              thanks man i got that with all ur help

              Comment

              Working...