Solved

DOevents question

Posted on 1998-09-16
1
205 Views
Last Modified: 2010-04-30
I am writing a serial interface program and use the loop to poll the data from buffer. In the loop there is a Doevents to return the control to the OS. If during the Doevents period the user press stop button, can I get out of the loop that I was running and do something else?
0
Comment
Question by:Overflow
1 Comment
 
LVL 4

Accepted Solution

by:
trkcorp earned 50 total points
ID: 1435339
Yes. That is the purpose of DoEvents, to allow a break in a hard loop. In order to make this work though you will have to be able to detect that the button was clicked from within your hard loop and then take appropriate action.  For example:

Option Explicit
Dim bStop as Boolean

Private Sub cmdStop_Click()
bStop = True
End Sub

Sub HardLoop()
Do
  DoEvents
  If bStop then Exit Do 'or maybe Exit Sub?
Loop
End Sub

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question