dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] End a procedure in execution?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    54

    Resolved [RESOLVED] End a procedure in execution?

    Hi people..
    It's me again..
    Based on the code below..
    How do I stop the execution of the codes at a certain lines if a certain condition is fulfilled?

    Code:
        Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            If trbShortest.Value + trbFastest.Value + trbCheapest.Value > 10 Then
                MessageBox.Show("Value too little/high!")
                trbShortest.Value = 0
                trbFastest.Value = 0
                trbCheapest.Value = 0
    // If condition is true then execution stops here.. Else execution continue on the lines below
    
            End If
    MessageBox.Show("This will occur if the condition is false")
    // More codes below...

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,483

    Re: End a procedure in execution?

    You can use a Return statement to break out of a method at any time. You can also use Exit Sub but Return is preferable.

  3. #3

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    54

    Re: End a procedure in execution?

    Quote Originally Posted by jmcilhinney View Post
    You can use a Return statement to break out of a method at any time. You can also use Exit Sub but Return is preferable.
    Cool!
    It worked!
    Thanks alot man..

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width