Results 1 to 3 of 3

IF true then Exit sub ?

Threaded View

  1. #1
    Registered User
    Join Date
    10-31-2008
    Location
    asia
    Posts
    32

    IF true then Exit sub ?

    Hi all,

    Quick Questions. I was looking up Subs on the internet and found this code.

    Sub computeArea(ByVal length As Double, ByVal width As Double)
        ' Declare local variable.
        Dim area As Double
        If length = 0 Or width = 0 Then
            ' If either argument = 0 then exit Sub immediately.
            Exit Sub
        End If
        ' Calculate area of rectangle.
        area = length * width
        ' Print area to Immediate window.
        Debug.WriteLine(area)
    End Sub
    The "Exit Sub" in the middle of the code, does it exit from the "IF" statement it is in, or the entire "Sub computerArea()?" If it only exits the if statement, how can I make it exit the entire "Sub computerArea()" because I have a code that needs to be exited when the if statemet (in the middle of my code)is true.

    Thank you for your time
    Last edited by VBA Noob; 11-26-2008 at 03:25 AM. Reason: Added code tags as per forum rules

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1