How to check for problems with the ECI and EPI classes
when starting methods, using Visual Basic and VBScript.
One way of handling exceptions is to use the ErrorWindow method
and set it to false, then check the ExCode and ExCodeText methods
after a call to see what the return codes are. The ErrorWindow method
is not the recommended way and exists only to support compatibility
with earlier versions for old applications.
The recommended way os handling exceptions is to use the Err objects
which Visual Basic and VBScript provide. An Err object contains the
information about an error. Visual Basic supports On Error
Goto and On Error Resume features to detect
that an error has occurred. VBScript only supports the On
Error Resume Next feature. If you use On Error Resume
Next either in Visual Basic or VBScript, you must always
enter this line before any COM object call that you expect could return
an error. Visual Basic/VBScript might not reset the Err variable unless
you do this.
The type of interface you have selected (you DIM'ed a variable
as either Object or classname) will affect the value contained in
the Err.number property. It is possible to write a generic routine
that handles all values in Err.Number and converts them to the documented
ExCode error codes available. The example code following shows how
to achieve this.
To get full advantage of this technique, ensure that you get full
information in the Err object. Issue the following call after creating
the ECI object:
ECI.SetErrorFormat 1
or, for
EPI:
EPI.SetErrorFormat 1
The following sample shows how to handle errors in Visual Basic.
The following sample shows error handling code for VBScript.