Sorry if this is a basic question but can I terminate the actions of parent subs from within a lower sub?
For example;
So if the user clicks a button which calls the MainSub and something nasty happens, I dont want the execution to continue through all remaining loops, but I also dont want to close the application.VB Code:
Private Sub MainSub For i = 1 To 500 TopSub() Next End Sub Private Sub TopSub() For i = 1 to 1000 'Call the lower sub LowerSub() Next End Sub Private Sub LowerSub() Try 'Do stuff Catch 'I want to be able to terminate any further execution of "Main" 'from here if things go badly wrong (but leave the form up) End Try End Sub
Since some subs are functions, it makes it hard to pass an "OK" var up from each and every sub to its parent. I'm hoping there's a nifty command like Application.StopExecution(MainSub) or similar.
I have this issue because I'm cycling through file accesses over the internet and if I get an authentication error or a timeout, I want to offer the user the opportunity to abort any further processing and let them fix the problem.




Reply With Quote