Results 1 to 3 of 3

Thread: Break from SUB?? SIMPLE??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181

    Break from SUB?? SIMPLE??

    hi..

    i have

    Private sub something_click()

    If Trim(txtCustomerName.Text) = "" Then
    msgbox "Customer name required.", vbCritical, "Required"
    ***
    End If

    ^other code here^
    ^other code here^
    ^other code here^
    ^other code here^
    ^other code here^

    End Sub

    where the *** are i want to stop executing the code the ^other code here^
    ...like just break out of the subroutine, how do i do that? isn't there a break or something?

    sorry, i'm used to java, which has a break statement, anything equivalent in VB?

    --770

  2. #2
    Member
    Join Date
    Oct 2002
    Posts
    33
    Try Exit Sub, I think that's all you need in that place precisely ( where the * * * )

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Use Exit

    Exit For
    Exit Loop
    Exit Sub
    Exit Function
    Exit Property
    Etc (If there are any more)

    Exit Sub is the one you'll want to use.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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