Right clicking in the code window will access the following functions

Add Error Handling
Also available by pressing Ctrl+Shift+E

(Can also be accessed in the project window to add error handling to a whole module or project)

My implementation of error handling is really quite simple.


All errors detected at the highest level of code (usually the control events) are reported to the user by calling an error logging procedure. This procedure can be enhanced to log the error to the event log or wherever.

All errors detected at lower levels are re-raised; this causes the error to be raised in the calling procedure.

The Err.Source property is modified to provide the error handling procedure with a call stack.

Special attention must be applied to the
Class_Initialize event in ActiveX Dlls and EXEs: Error Handling should not be present; re-raising the error may result in an access violation. My recommendation is not to have any code in the Class_Initialize or to move the code from the Class_Initialize into a Private Sub and call this from the Class_Initialize.

Special attention must also be applied to the
Class_Terminate event: Error handling must be present: failure to handle errors will result in the program terminating. Be aware that the event can be invoked after an error elsewhere, so error handling in the Class_Terminate event could reset the error. An approach to circumventing this is to save and restore the error information. The add-in will add this code for you, but will not check it, modify it or remove it later (may be in future it will). The example ErrorLog now contains this code.

Error Handling in
User Controls is now slightly different: errors should not be raised to the calling application. An error reporting procedure should be called (there is a new field under the "Inserted Code" tab to allow you to configure this); you could, with in this procedure, raise an event back to the calling application.

Error Handling in
MTS Components is now handled separately. There are two separate tabs to allow you to specify error handling (for both normal and abnormal exit of the routine) within MTS components: in the default the SetAbort method is called for a module-level variable mctxObject which could be initialised in the ObjectControl_Activate event via Set mctxObject = GetObjectContext.

When using MTS error handling should not be present in the ObjectControl_CanBePooled and ObjectControl_Deactivate events as error information would be lost. By default error handling will not be added to these two procedures and the ErrorSave and ErrorRestore procedures. This list of procedure names can be maintained via the options tab.

Configuration

Under the options tab there are a number of configuration tabs that allow the automatically inserted text to be specified. The tabs should be self-explanatory.


Add Line Numbers
Also available by pressing Ctrl+Shift+L

(Can also be accessed in the project window to add line numbers to a whole module or project)

Line numbers can be added to procedures. When an error is detected the line number is moved into the "Erl" variable, which can then be used in the error handling procedure. Inserting line numbers will first remove any existing ones and tidy the code (see below).

Tidy Procedure Also available by pressing Ctrl+Shift+T

(Can also be accessed in the project window to tidy a whole module or project)

This part of the add-in will indent the code using tab stops; it should handle most, if not all, statements. Nested statements will be given an extra tab. It will make your code look tidy and is quicker than doing it manually. Line numbers will be removed and multiple blank lines will be condensed to a single one.

Close Windows Also available by pressing Ctrl+Shift+W

This will close selected windows (these can be configured via the full-screen interface): especially useful when you get a bit carried away and have nearly all of the modules and forms open.

Add Comment Also available by pressing Ctrl+Shift+C

When changing code it can be useful if a comment is added explaining why the change has been made. This part of the add-in will, by default, add a comment with the current date and the user id positioning the cursor ready for the comment.

Find Also available by pressing Ctrl+Shift+F

This will allow searching across a project group, with the results being listed in a treeview.

A command line interface is also available when compiles are initiated
This is only available in the VB6 version.

If compiles are initiated from the command file using the "/m" or "/make" option then the following options can be specified after the "/c" or "/cmd" option:

/kdcheck

This will check that error handling is present in the project components. It must be used in conjunction with the /kdout option. Be aware that when controls are present within a component (a form for example) the add-in will cause the component to be displayed.

/kdline

This will re-apply line numbers to the code (only where the components are not read-only). Details will be written to the file specified after the /kdout option.

/kdtidy

This will re-indent the code (only where the components are not read-only). Details will be written to the file specified after the /kdout option.

/kdout filename

Specifies a file to receive details of the findings and actions from the other two options.