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.
Arrow Keys
Collapse
X
-
Tags: None
-
Originally posted by DarkDude110I'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. -
Originally posted by Killer42You 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 keypress use keyascii to check
Remember theh key TAB is not get tressed in any event
in keyascii arrow keys are not get tressed
byeComment
-
Originally posted by vijaydiwakarin 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
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
-
Originally posted by Killer42That'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
-
Originally posted by vijaydiwakardo u have any idea how to tress the tab key when a no of ctrls are placed on the form
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
-
Originally posted by Killer42Can 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
Comment