What is the syntax to exit a procedure?

Exit Sub
#example - exits procedure if something error description happens
Private Sub btnAddNew_Click()
errorStr = errorCheck 'checks for errors ie. missing gaps in textfields

If Not (errorStr = "") Then 'if something wrong with wat user entered
     Exit Sub
End If

End Sub
Advertisements

What is the syntax to use a Go Sub Return statement?

Go Sub <procedure name>
     <your code here>
Exit Sub

<procedure name>:
     <your code here>
Return
‘example
usersName = InputBox(“Please enter your name.”) ‘1. user must type in his/her name
If usersName=”” Then GoSub NoName ‘2. if user doesn’t give a name, computer goes to sub procedure NoName
Exit Sub ‘5. Put exit sub so it will not run NoName unnecessarily

NoName: ‘3. This procedure is run only if user leaves inputbox blank
     MsgBox (“You did not enter any name”)
Return ‘4. returns to line procedure