I have an object, say Order
where if an error occurs, it raises the ErrorOccurred
event. If I'm running some code in say, the codebehind for a .aspx page with an public Order
registered as WithEvents
and I want to check to see if an error has occurred before I run more code, how do I do this? I can't simply check theOrder.ErrorOccurred
. Do I have to create a local boolean flag that switches over in the event handler (OnErrorOccurred
)? Or is there a better way to do this?
Thanks!
Example:
Public WithEvents theOrder As New Order
Public Sub DoStuff()
theOrder.DoSomething()
If theOrder.ErrorOccurred Then
do stuff
End If
End Sub