New Procedure Builder
Use the New Procedure Builder to quickly create new
procedures in your VB6 and Microsoft Office/VBA projects. Simply
type in a procedure name, set the options you want, and see your
new procedure built piece by piece:
The code automatically applies your commenting, error
handling, visual style settings, and naming conventions. Press
[OK] to insert the code directly into your project at your
cursor, or send it to the clipboard, file, or notepad.
New Procedure Results
With a few mouse clicks, you take a name, GetCustomerID, and
quickly create an entire procedure with your commenting, error
handling and other specifications:
Private Function GetCustomerID() As
' In :
' Returns :
' Created : 05/08-LC
FMS_PushDebugStack Me.Name & ".GetCustomerID"
If gcfHandleErrors_FMS Then On Error GoTo PROC_ERR
GetCustomerID = 0
In the example above, you can see:
- The procedure is Private
- The function return type is a Long Integer
- The comment section at the top of the procedure includes
the date and developer initials. This makes it easy to
document every procedure you create.
- A line is added for the function to return a default
long value (0) which you can easily update
- The error handler is broken into two sections.
- The Error Enabler (two lines at the top)
This error enabler passes the current procedure name to
a procedure which tracks the procedure stack of the
application. It is passed the procedure name using the
#P# token. Because it's the Form/Report error handler,
it also references the Me.Name of the object so that the
name of the form/report is also passed.
- Error Handler (the lines at the bottom starting with
The error handler automatically adjusts to use Exit
Function or Exit Sub based on the procedure type
Your comment and error handler structures are defined under
the Standards button and apply to several parts of Total Visual
CodeTools. Once defined, Total Visual CodeTools makes it easy to
replicate it whenever you create a new procedure. The settings
can also be shared across your entire team so multiple
developers use a consistent style.
Procedure Design Options
Here are the details of each New Procedure Builder option.
See how easy it is to create your new procedures by selecting
in your new procedure type, or use the procedure name where your
cursor is (helpful if you want to add your comment and error
handling structure for an event procedure already created by
Specify the scope of the procedure to default (none), Public,
Private, or Friend:
Determine whether you want it to be a Sub or Function. If
it's a function, you can define the return data type, and
optionally assign a return value.
options that let you determine whether you want to:
- Include your custom comment structure. The comment
section can include things like the current date and time,
your initials, etc.
- Only have the body of the procedure (eliminate the first
Sub/Function line and the last End Sub/Function line).
Useful when inserting your comment/error handling text in an
existing event procedure.
error handling is key to professional VB6/VBA development. Total
Visual CodeTools offers three sets of custom error handling
routines you can specify. If you define your error handlers for
Module, Class, and Form/Reports, you can choose which one you'd
like to use for your new procedure:
The Error Handler can insert your procedure name, module
name, the procedure type (to use Exit Sub or Exit Function),