VB.Net 2010: Stop code execution, but stay in form
Posted on 2014-08-25
The question is pretty simple. If I encounter an error, and I'm running VB.Net from the executable file I created, I would like to write code that allows me to abandon the execution and send the control back to the functional form. If the error occurs from a deeply embedded place within code, my strategy has been to create an elaborate architecture of sending the error code back up the successive ranks, finally getting to the original calling routine, from which exiting sends control back to the form. I'm looking for a shortcut to perform the same thing.
The "Exit Function" and "Exit Sub" routines take me out of the problematic subroutine or function, but the code continues executing from whatever process in which the errant routine was embedded, such as a "for" or "while" loop. On the other hand, "End" effectively stops all processes, but also has the undesirable side effect of shutting down the form. If I encounter an error with my input, I want to be able to stop code execution while leaving the form open, allowing me to modify parameters and try again.
I'm looking for a statement that is more encompassing than "Exit" but stops short of the finality of "End" (a wished-for routine one might call "Exit All"). Does such a thing exist?
Thanks! ~Peter Ferber