Afternoon folks. Apologies if this is the wrong subforum; as always in my case, this question could be either construed as a form question or a VBA question, for once I've stuck it in the VBA section.
A button's On Click event on one of my forms runs a For...Next loop that I want to break out of if the user clicks a particular key, such as modifier key or escape. I know that's not the greatest programming practice in the world, but sometimes needs must. So I need to I need to detect a keypress while the code inside an On Click event is busy, therefore I can't rely on the Key Down event etc. To detect modifier keys from inside an active event I usually slap something like:
...in a module and refer to that, e.g.: intX = GetKeyState(vbKeyControl) tests the control key. But this doesn't seem to work inside the For...Next loop. It's as though the keyboard isn't being scanned while the event is active. Any better ideas?
Thanks
A button's On Click event on one of my forms runs a For...Next loop that I want to break out of if the user clicks a particular key, such as modifier key or escape. I know that's not the greatest programming practice in the world, but sometimes needs must. So I need to I need to detect a keypress while the code inside an On Click event is busy, therefore I can't rely on the Key Down event etc. To detect modifier keys from inside an active event I usually slap something like:
Code:
Public Declare Function GetKeyState Lib "user32" (byVal nVirtKey As Long) As Integer
Thanks
Last edited: