Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Gurus*
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...