Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program Hangs

Status
Not open for further replies.

007MCSE

IS-IT--Management
Jan 3, 2003
51
US
I've got a Program running an endless Loop With a do while events.

Private Sub Timer1_Timer()
Static Temp As Integer
Temp = Temp + 1
Do While DoEvents()
If Temp Mod 2 = 0 Then Exit Do
Loop
End Sub

When the program is running, if you move the form with the mouse. The program locks up.
I know its because of the Do While Do Events.

But how do I stop this happening?
 
I do not believe you will get another Timer event until you exit the current one. Usually you get DoEvents = 0 so you break out of the Do/Loop. If, however, there are pending MouseMove events and Temp Mod 2 = 1 then you will never break out of the Do/Loop because another Timer event can not occur. step through in debug mode.

Try
Debug.Assert Not( DoEvents > 0 and Temp mod 2 = 1)
to stop when the loop should occur and see if you ever re-enter the Timer event. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top