mike55 Posted August 11, 2006 Posted August 11, 2006 Hi When I create a method in vb.net, I can specify that the parameters passed are byVal or byRef. I tend to use the byRef when I want to return an error code if an exception is caught. My question therefore is: 1. Is the use of byRef for passing error codes the correct approach? or is there a more effective approach especially if my functionis designed to return say a dataset? Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted August 11, 2006 Administrators Posted August 11, 2006 The best way to signal an error is just by using exceptions. If the routine you are calling has handled the error why does the calling routine need to know? If on the other hand the called routine isn't handling the exception then it shouldn't be catching it. As a rule you should use parameters for passing information into a routine and a return value for returning a result. If there is an unhandled error then signal this by either throwing an exception or just allowing the exception to propagate up the call stack. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.