Results 1 to 6 of 6

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

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    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 2011
    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
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    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 don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * 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??? *

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

    Re: Stop Button Code Execution at some point?

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

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Stop Button Code Execution at some point?

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

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    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
  •  



Click Here to Expand Forum to Full Width