Arrow Keys

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DarkDude110
    New Member
    • Feb 2007
    • 1

    Arrow Keys

    I'm very new to visual basic and i'm currently using Visual Basic 6. I've been trying to figure out how to make things happen when you press an arrow key. I've tried a few differant ways but for some reason I cannot get it to work. I don't want to use anything to advanced since I'm only a freshmen in highschool and were only halfway through the year. (My teacher goes so slow were still on For Next and Do While loops.) Any help would be appreciated.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by DarkDude110
    I'm very new to visual basic and i'm currently using Visual Basic 6. I've been trying to figure out how to make things happen when you press an arrow key. I've tried a few differant ways but for some reason I cannot get it to work. I don't want to use anything to advanced since I'm only a freshmen in highschool and were only halfway through the year. (My teacher goes so slow were still on For Next and Do While loops.) Any help would be appreciated.
    You could try setting the form's KeyPreview property (to make sure the form sees the keys before any controls do), then use the KeyDown or KeyUp event.

    Comment

    • vijaydiwakar
      Contributor
      • Feb 2007
      • 579

      #3
      Originally posted by Killer42
      You could try setting the form's KeyPreview property (to make sure the form sees the keys before any controls do), then use the KeyDown or KeyUp event.
      in Keydown use keycode to check
      in keypress use keyascii to check

      Remember theh key TAB is not get tressed in any event
      in keyascii arrow keys are not get tressed

      bye

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by vijaydiwakar
        in Keydown use keycode to check
        in keypress use keyascii to check

        Remember theh key TAB is not get tressed in any event
        in keyascii arrow keys are not get tressed
        That's not entirely true, though for practical purposes it's close enough.

        The Tab key can be detected in both the KeyDown and KeyPress events. The code is 9 (or vbKeyTab) in both cases. Unfortunately, this seems to apply only to an empty form. Once you place a control on the form, it appears to absorb the KeyPress, but KeyDown is still triggered. If you place more than one control (and let's face it, when wouldn't you?) then it becomes undetectable. What a pain.

        And yes, as you say vijaydiwakar, the arrow keys only show up in the KeyDown and KeyUp events, not KeyPress.

        Comment

        • vijaydiwakar
          Contributor
          • Feb 2007
          • 579

          #5
          Originally posted by Killer42
          That's not entirely true, though for practical purposes it's close enough.

          The Tab key can be detected in both the KeyDown and KeyPress events. The code is 9 (or vbKeyTab) in both cases. Unfortunately, this seems to apply only to an empty form. Once you place a control on the form, it appears to absorb the KeyPress, but KeyDown is still triggered. If you place more than one control (and let's face it, when wouldn't you?) then it becomes undetectable. What a pain.

          And yes, as you say vijaydiwakar, the arrow keys only show up in the KeyDown and KeyUp events, not KeyPress.
          do u have any idea how to tress the tab key when a no of ctrls are placed on the form

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by vijaydiwakar
            do u have any idea how to tress the tab key when a no of ctrls are placed on the form
            Can we just clarify what you mean by "tress", please?

            Definition of TRESS: braid: a hairdo formed by braiding or twisting the hair

            And no, sorry, I don't know how to tell when the user hits the Tab key. If someone else does, I'd be curious to find out.

            Comment

            • vijaydiwakar
              Contributor
              • Feb 2007
              • 579

              #7
              Originally posted by Killer42
              Can we just clarify what you mean by "tress", please?

              Definition of TRESS: braid: a hairdo formed by braiding or twisting the hair

              And no, sorry, I don't know how to tell when the user hits the Tab key. If someone else does, I'd be curious to find out.
              thanx for compliments

              Comment

              Working...