Hey Guys,
I am trying to stop processing code in a class and return to the from with an error. When it ty the return; method it only takes me out of the class and back into the form class and keeps executing code.
What is the code that I should use to return to my form.
Thanks,
Loading
AlanPosted Dec 6, 2007, 5:32 AM
Ryan AlfordPosted Dec 5, 2007, 10:29 PM
Blake ArnoldPosted Dec 5, 2007, 7:29 PM
I was thinking if I set it to bool then I can just run a simple if loop to check wheather it worked or not.
Thanks,
Blake ArnoldPosted Dec 5, 2007, 7:24 PM
AlanPosted Dec 5, 2007, 6:41 PM
If you're calling a class method from your form, then try placing the method call inside a try/catch block. Any exceptions which are thrown but not handled by the code in the class method, should then be caught and handled in the form.
Alternatively, if you want to handle the exception in the class method but indicate to the form that the exception has occurred, use the return value of the method, or a 'ref' parameter, to notify the error. The code in the form can then examine the return value or 'ref' parameter to see whether an error occurred and, if it did, take the appropriate action.