When using Sub's, if I'm not returning a value, is it necessary to use:
Public Sub whatever()
...
Exit Sub
End Sub
instead of just
Public Sub whatever()
...
End Sub
Do I gain anything (memory, speed, etc.) by using "Exit"?
Does the Sub exit anyway when it is done even if I don't use the "Exit" statement?
Thanks.
In this particular case Exit Sub
is completely unnecessary. It can be used there but is generally considered bad style. The statement is necessary when you want to prematurely leave the method. For example if you detect a specific condition is met and you don't want to execute the rest of the method
Public Sub Example()
If SomeCondition Then
Exit Sub
End If
' Do other work
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With