On 2010/11/11 18:50, OliE wrote:

I found something I find weird in one of his try catch in his code.
Instead of having multiple catch of different error types, he made
this :

         Catch ex As Exception
             If ex.Message = "IOException" Then
                 MsgBox("Communication Error")
             Else
                 MsgBox(ex.Message) 'ex.Message
             End If

I told him no to do so and use multiple catchs like this :

         Catch exIO As IO.IOException
             MsgBox("Communication Error")

         Catch ex As Exception
             MsgBox(ex.Message)

Second way is better!

In the first case, the statement

 If ex.Message = "IOException" Then

is wrong. The Message property of an Exception, rarely contains something as simple as "IOException". A better method would have been

 If ex.Message.Contains("IOException") Then

--
Regards,
Mike Fry
Johannesburg

Reply via email to