VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 11

Properties of the Err Object - Description Property

A brief description of an error is available in the Description property of the Err object. The text corresponds to the error identified by Err.Number.

When a runtime error occurs in a Visual Basic application such as a division by 0 or an overflow, the Err.Number and Err.Description properties get set and can be used to handle the error or display information to the user. The easiest way to display error information is with a message box, as follows:

Msgbox Err.Number & "-" & Err.Description

Where you code this message box depends on how you have implemented error handling for your application (see the section "Handling Errors in Code").

As with the Err.Number, the Err.Description can be set in code. If you set the Err.Number property in your code, you should also set the Err.Description property to provide a description of the error. If you do not set the Description property and you use an error number recognized by Visual Basic, the description will be set for you automatically.

If Visual Basic does not recognize the error, it sets the Description property to Application-Defined or Object-Defined Error. This is discussed in more detail later in this section, under the section titled "Raise Method."


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved