How to identify the try catch error number?

Posted on 2010-01-06
Last Modified: 2013-11-26

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


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

Question by:concern_support
    LVL 11

    Expert Comment

    You can split the ex.Message in catch block. Then write
    LVL 9

    Expert Comment

    LVL 3

    Expert Comment

    The HResult member of  the Exception Object contains the Actual Error Code...
    The Message as you're already aware contains the accompanying error Text...

    Author Comment

    for example how? Can you tell me how to give a friendly message when there is primary/foreign key conflict?
    LVL 9

    Accepted Solution


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now