Micher in the new sub, just do Throw new myexception
Sub New()
mybase.New()
If condition Then
Throw new MyException()
End If
End Sub
Then on the caller you have the
Try
dim myClass as new MyClass
Catch ex as myexception
do something
Catch ex as exception
do other thing
End Try
>>Michel what I do is raise an exception that I catch on the caller class.
>
>How would you raise an exception in the New() event of the class?
>
>For now, I have adding a property lStop to the class. Then, from the object New() event, if I set this to True, when the call will be done to the method, it will know that it has to return. This class only contains one method to initiate the required procedure, thus I verify that property at first. But, it will still be useful to have a better way to do this because in some classes, I might have several methods available for specific procedures and I would need to detect that prior to calling those methods.
Alexandre Palma
Senior Application Architect