on error?

Salat

Well-known member
Joined
Mar 5, 2002
Messages
81
Location
Poland, Silesia
Im new to VB.NET Im trying to catch some errors in the sub. But I found out that there is no "ON ERROR" command. What shell I use then?

And some other question about errors.

If Im useing WebClient control, which doesnt have any events, which may corespond with its status. There are errors generated, when time-out etc. How shell I then catch the error for this control?

thanks for helping me... Piotrek
 
Code:
Try
    Place code here that may cause an exception
Catch e1 As ArgumentException
    Handle all exceptions that are of type "ArgumentException"
Catch e2 As ArgumentNullException
    Handle all exceptions that are of type "ArgumentNullException"
Catch e3 As FileNotFoundException
    Handle all exceptions that are of type "FileNotFoundException"
Catch e4 As Exception
    Handle all other exceptions that werent specifically handled above
End Try

Of course the type of exceptions are going to differ depending on the type that might be thrown, so make sure to customize each Try/Catch block for the code it contains. The ones I listed above were the first to come to mind, and are definately not appropriate for all situations.
 
Back
Top