I need to interrupt a For Each loop (i.e. Exit Sub) and then later resume it. The loop currently looks like this:
For Each pnl As Panel In ListOfCmtPanels
pnl.SuspendLayout()
For Each cntl As Control In pnl.Controls
If cntl.GetType Is GetType(OrigCmt) Then
Dim oc As OrigCmt = DirectCast(cntl, OrigCmt)
oc.ChangeCmt()
progbar.Increment(1)
End If
Next
pnl.ResumeLayout()
NextNow I need to check a flag in that "oc" thing and if it is set do an Exit Sub but then later (when the user clicks a Resume button) continue processing following the point of interruption.
I'd like a slick way to do this. But if there is no slick way then I know how to just skip over previously processed itemsso long as For Each presents objects in a predictable order. If I do not add or remove controls from the panels will the controls always be presented in the same order?
Thanks, Bob