Application.Quit out of Do loop

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

While doing some housekeeping on some old VBA procedures, I stumbled on this
anomaly of Application.Quit not executing out of a Do loop. Just wondered if
someone can explain why it is necessary to Exit Do before the Quit method
will execute?
 
VBA's ability, on the odd occaision, to obfuscate what must be underlying
machine code logic, to a mirage of strange magic, leaves me stunned- Just as
well we love it eh?
 
See the difference of commenting out the DoEvents.

Private Sub CommandButton1_Click()
Dim i As Long, j As Long

For i = 1 To 100000
For j = 1 To 100000
If i = 500 And j = 1000 Then Application.Quit
Next
Debug.Print i, j
DoEvents
Next

End Sub

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top