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

Using the vbObjectError Constant

When you return error information from a class module, you must be aware that some special handling is required. If you want to generate a certain numbered error in a class module, you should add a constant number, vbObjectError (a number in the range of negative two billion on most systems), to your error number before you invoke the Raise method. You should do this to signal the error is generated in the class object but raised to the calling routine or application.

If you wanted to raise error number 500 in your class module, for example, you would invoke the Err.Raise method and pass vbObjectError + 500 as the error number. The calling program or module interpreting the runtime error generated by the Raise method should then strip off the vbObjectError constant to interpret your error.

NOTE - Error Numbers That You Can Use: Currently not all the numbers between 0 and 66,535 are being used by Visual Basic. Some of the numbers are used; others are being reserved for future use. Using the vbObjectError enables you to define your own error numbers. It also prevents rewrite in the future—when later versions of Visual Basic that use more error numbers are released.


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved