devxlogo

Checking for Cancel in Loop

Checking for Cancel in Loop

Question:
I have started using VB3 yesterday to do a small project. I use Access normally. I wish to set use one button to initiate a loop and another button to stop the loop.I have seen your response to a similar question where you said to set a flag to false in the second button and to check for it in the loop. However I cant seem to get the program to allow me to click the second button when it is running.Can you show me some snippets of code?

Answer:
Within the loop right before you check the flag, put in the DoEvents statement. That will tell the system to check to see if any Windows events have happened and to process them. Otherwise, the program will seem to ignore the button press.

See also  Monetize TikTok For Your Business
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist