Detect a keypress during a Loop

Daveyk01

Registered User.
Local time
Today, 03:30
Joined
Jul 3, 2007
Messages
144
Okay, I feel silly. Haven't done that in so many years (since Visual Basic Deveolpement System for DOS, or earlier versions in the '80s....

In a loop what is the best way to detect if a user presses a key (i.e., ESC)?

I feel silly asking since it is probably so easy.... this morning my brain is locked.
 
Don't feel excessively silly. This is not a trivial problem and most of the 80's happened more than 20 years ago. :eek:
Look up DoEvents, which cedes execution control to pending events.
 
Not to be a perfectionist, but VB1 came out in 1991, as did PowerBuilder. ;) I'm thinking you're remembering QuickBasic, perhaps?
 
Not to be a perfectionist, but VB1 came out in 1991, as did PowerBuilder. ;) I'm thinking you're remembering QuickBasic, perhaps?

Perhaps. My main project was a program to manage a small calibration lab and produced NIST traceable certificate (NBS) and tracked the asset equipment. I am pretty sure I used both QuickBasic and the then Professional Basic Developement System (not VB - sorry) with several add-ins. I remember the add-ins as giving ZIP ability and the an add-in to fully support DBF file format.
 
Don't feel excessively silly. This is not a trivial problem and most of the 80's happened more than 20 years ago. :eek:
Look up DoEvents, which cedes execution control to pending events.

Okay here's what I did and it works.

In the "ON KEY PRESS" event for the button that starts the loop, I set an invisible field to "true" on the form. Then once a loop, I look to see if that invisible field is true, if it is, exit the loop/sub/etc.

It works as long as the button maintains focus.

I am thinking the old command in PBDS/Quickbasic was "OnKeys" in the loop?
 
Have you considered using the OnKeyPress event of the form itself instead of the specific control?
 

Users who are viewing this thread

Back
Top Bottom