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
 
Back
Top