Erik Johnson
February 10th, 2000, 03:18 PM
I am trying to implement some structured exception handling (VC++ background). How do I throw an exception in VB?
Thanks in advance
Erik Johnson
Erik Johnson
Thanks in advance
Erik Johnson
Erik Johnson
|
Click to See Complete Forum and Search --> : How do I throw an exception in VB? Erik Johnson February 10th, 2000, 03:18 PM I am trying to implement some structured exception handling (VC++ background). How do I throw an exception in VB? Thanks in advance Erik Johnson Erik Johnson Weasel February 10th, 2000, 03:46 PM They're called events in VB I believe. Declare them at the top of the module that uses them and call them with RaiseEvent. Event foo() Private Sub Command1_Click() RaiseEvent foo End Sub Though when you think about it, how "structured" *is* the exception system? Return values for success or failure are more structured, exceptions are nothing but GOTOs. Erik Johnson February 10th, 2000, 03:55 PM Hmm... In VC++ you can throw an exception and pass back a strucure or an error class and have multiple handlers triggered on the type of class being returned. I am guessing that there is no equivelant in VB? Layering function error return types does not sound fun but I guess it's do-able. Thanks for your help, Erik Erik Johnson BobClarke February 10th, 2000, 04:43 PM >> Return values for success or failure are more structured, exceptions are nothing but GOTOs Do you mean this in a VB context, because exceptions are certainly more than that in some other languages (C++ and Java: stack is unwound and destructors are called without the programmer having to code anything)? I'm not very familiar with VB or its exception handling abilities, so I'm just asking. February 10th, 2000, 10:20 PM Weasel: No, I believe you can declare them with variables, but the *concept* of an exception is too haphazardly break from a *general location* exact point unknown to throw execution somewhere else entirely. Give it an arg list and it should work fine. And as opposed to passing structures, there's always that one other hated method of passing large and/or complex things. (But extremely useful) Global vars! codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |