Results 1 to 6 of 6

Thread: [RESOLVED] Stop Button Code Execution at some point?

  1. #1
    Lively Member
    Join Date
    Apr 10
    Posts
    107

    Resolved [RESOLVED] Stop Button Code Execution at some point?

    Is there any way to stop the execution of the code that's under a button if for example a certain condition is met?

  2. #2
    Fanatic Member proneal's Avatar
    Join Date
    May 11
    Posts
    762

    Re: Stop Button Code Execution at some point?

    Yes OP there are several ways/methods.
    Here is a basic one, using Flag to halt a Loop.

    vb Code:
    1. Dim StoppingExecution as Boolean =False

    Your Loop could be like this:
    vb Code:
    1. Do until StoppingExecution
    2.  
    3. ' code to execute in here
    4.  
    5. Loop
    -
    Do { While | Until } condition
    [ statements ]
    [ Exit Do ]
    [ statements ]
    Loop

    -

    Good Luck!

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,653

    Re: Stop Button Code Execution at some point?

    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

  4. #4
    Addicted Member vb_ftw's Avatar
    Join Date
    Dec 10
    Posts
    139

    Re: Stop Button Code Execution at some point?

    or:
    vb Code:
    1. iif (mycondition,on true Exit Sub,nothing)

  5. #5
    Burning Member Niya's Avatar
    Join Date
    Nov 11
    Posts
    3,101

    Re: Stop Button Code Execution at some point?

    vbnet Code:
    1. Threading.Thread.Sleep(System.Threading.Timeout.Infinite)
    Suspends code execution indefinately.

  6. #6
    Lively Member
    Join Date
    Apr 10
    Posts
    107

    Re: Stop Button Code Execution at some point?

    Quote Originally Posted by vb_ftw View Post
    or:
    vb Code:
    1. iif (mycondition,on true Exit Sub,nothing)
    The simple code Exit Sub does the job perfectly, I just didn't remember it cuz I knew I had used it somewhere before, so Thank You Very Much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •