We help IT Professionals succeed at work.

Determine Exception Type

Torrwin
Torrwin asked
on
Hello,

I have a 3rd party control that has an Error() event.

One of the arguments for the error event is Control.ErrorEventArgs.

So, if I wanted to see what type of exception occured, I could use:
MsgBox(e.Exception.GetType.ToString)

My question is: How do I write an IF statement to handle specific errors?  I can't use a catch block because this is an event.

The following does not work because "'FormatException' is a type in 'System' and cannot be used as an expression":
If e.Exception.GetType Is System.FormatException Then...

Thanks,
-Torrwin
Comment
Watch Question

Director of Information Technology
BRONZE EXPERT
Commented:
Try this:

If e.Exception.GetType Is GetType(System.FormatException) Then...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.