on error?

Salat

Regular
Joined
Mar 5, 2002
Messages
81
Location
Poland, Silesia
I'm new to VB.NET I'm 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 I'm useing WebClient control, which doesn't have any events, which may corespond with it's status. There are errors generated, when time-out etc. How shell I then catch the error for this control?

thanks for helping me... Piotrek
 
Visual Basic:
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 weren't 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