Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DOevents question

Posted on 1998-09-16
1
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
trkcorp earned 200 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

618 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