PDA

View Full Version : Solved: Returning an Error Indicator in a Function



Cyberdude
10-12-2005, 10:44 AM
I wrote a function in which I did some error checking on the argument. The function has a boolean return of True or False. If the error checking detects an error, how does one return something that indicates an error occurred? I thought about having two args, one being RC (return code), but that complicates the invocation of the function. Normally a function is referenced by a statement like:
If RangeIsEmpty(RangeVal) Then ...
If I included an RC argument, then I'm not sure how I'd invoke the function to get first the return code, then the function value. The only other thing that comes to mind is to "Raise" an error condition, which is rather sloppy.
Any suggestions? http://vbaexpress.com/forum/images/smilies/119.gif

Bob Phillips
10-12-2005, 10:47 AM
I wrote a function in which I did some error checking on the argument. The function has a boolean return of True or False. If the error checking detects an error, how does one return something that indicates an error occurred? I thought about having two args, one being RC (return code), but that complicates the invocation of the function. Normally a function is referenced by a statement like:
If RangeIsEmpty(RangeVal) Then ...
If I included an RC argument, then I'm not sure how I'd invoke the function to get first the return code, then the function value. The only other thing that comes to mind is to "Raise" an error condition, which is rather sloppy.
Any suggestions? http://vbaexpress.com/forum/images/smilies/119.gif

I use a variant return and return -1 for an error.

Cyberdude
10-12-2005, 10:53 AM
Great idea, xld. I'll do it! Thanx.