Re: Function return value
- From: "Jonathan West" <jwest@xxxxxxxx>
- Date: Sun, 18 Sep 2005 12:17:12 +0100
"Jay Freedman" <jay.freedman@xxxxxxxxxxx> wrote in message news:%23avUR%23suFHA.2212@xxxxxxxxxxxxxxxxxxxxxxx
The technical answer is, it *can* be done in several places; that is, example 1 will work.
The answer from experience is, it *should* be done only in one place, for a
couple of reasons. The main reason is to help prevent bugs, or to ease
debugging when the inevitable happens. This goes together with the general
rule that, except for error-handling, there should be only one exit point
for each sub/function.
Personally, I take a more relaxed view of this. I think that Example 1 is perfectly good code, and reduces the amount of jumping about within a routine and reduces the total number of lines of code.
There are cases where a single exit point would be advisable, such as where there is a need to restore global parameters (such as the position of the Selection) prior to exit. These issues need to be addressed on a case-by-case basis.
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
.
- References:
- Function return value
- From: Jay
- Re: Function return value
- From: Jay Freedman
- Function return value
- Prev by Date: Re: Run Macro on Opening a Document
- Next by Date: How To Set Up Global Constant / Variables for A Document
- Previous by thread: Re: Function return value
- Next by thread: Run Macro on Opening a Document
- Index(es):
Relevant Pages
|