How to identify the try catch error number?

Hi,

Is there any way to identify the error number return by catch block.

e.g

try
           statments
           staments
Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error!")
End Try

actually i want to know the error number and then with select case i want to give a friendly message to the user that e.g You are entering duplicate value, etc



concern_supportAsked:
Who is Participating?
 
ashraf882Commented:
You can split the ex.Message in catch block. Then write select...case.
0
 
chwong67Commented:
0
 
clintonljCommented:
YES...
The HResult member of  the Exception Object contains the Actual Error Code...
The Message as you're already aware contains the accompanying error Text...
0
 
concern_supportAuthor Commented:
for example how? Can you tell me how to give a friendly message when there is primary/foreign key conflict?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.