Is there any way to stop the execution of the code that's under a button if for example a certain condition is met?
Is there any way to stop the execution of the code that's under a button if for example a certain condition is met?
Yes OP there are several ways/methods.
Here is a basic one, using Flag to halt a Loop.
vb Code:
Dim StoppingExecution as Boolean =False
Your Loop could be like this:
-vb Code:
Do until StoppingExecution ' code to execute in here Loop
Do { While | Until } condition
[ statements ]
[ Exit Do ]
[ statements ]
Loop
-
Good Luck!
Yes. No. Maybe. Perhaps. Depends on the code.
-tg
* I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
*Proof positive that searching the forums does work: View Thread *
* How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
* How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
* Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
"There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
or:
vb Code:
iif (mycondition,on true Exit Sub,nothing)
Suspends code execution indefinately.vbnet Code:
Threading.Thread.Sleep(System.Threading.Timeout.Infinite)