jaffer's code is part of the solution. Supposing that a form is active during your function execution, the form can "listen" to keystrokes, especially if the form uses "keyboard preview" (so it doesn't matter which control has the focus).
The escape key can then toggle a global variable, "cancel requested". A [Cancel] button can also perform the same thing.
Your function would then perform as often as possible the sequence: DoEvents (to process any pending keystrokes) and "If gfCancelRequest Then... exit".
(°v°)
Main Topics
Browse All Topics





by: jjafferrPosted on 2009-11-04 at 02:23:39ID: 25737902
try this code
Keycode 27 is the Escape key
jaffer
Select allOpen in new window