Setting VBA/VB6 Module Coding Standards in Total Visual CodeTools
The Standards section of Total Visual CodeTools lets you specify the
settings that apply across the Code Builders, Code Cleanup, and Code
Delivery features. These settings are saved to a file which can be shared across
machines and developers. You can even password protect the
settings to enforce your standards across your team.
Available under the Standards menu item or the Standards
button on most tools, the settings are organized into these
sections:
Builder Settings
The Builder Settings specify the general options for the Code Builders.
These options are available:
- The number of spaces for each indentation (defaults to
your VB6/VBA editor setting)
- For word-wrapping, the maximum number of characters in
each line, and the use of line continuation character ( _)
at the end of the line
- An external editor, if any. The
builders can send its code to the project at the current
cursor position, the clipboard so you can paste it later, a
file on disk, or to an external editor like Notepad.
- Menu location to specify whether Total Visual CodeTools
appears at the top menu bar or under the Add-ins or Tools
menus.
Cleanup Style
The Cleanup Style settings are used with the Code Cleanup feature. When
you specify the Cleanup Style option under Code Cleanup, the selections here
determine how the VB6/VBA code is modified.

These options are available:
- Standardizing line indentations. If a line contains
multiple lines of code separated by colons, they are split
into individual lines
- Split single line IF statements into multiple lines with
END IF.
- Split single line declarations (Dim statements) into
multiple lines
- Specify the number of blank lines between procedures
- Specify the maximum number of blank lines within your
code
- Sort your procedures. For instance, you can have Public
procedures above your private ones
For examples of how these settings are applied, see the
Sample Code Cleanup.
Commenting
The commenting section is divided into six tabs:
- The General tab for settings that apply to all the
commenting options
- Code Cleanup commenting options:
- Cleanup Mod for comments to add in the General
Declarations section of modules (can include procedure
lists of the module)
- Cleanup Proc for the comments to add to procedures
- Cleanup Prop for the comments to add to properties
- New Proc for the comments to add in the New Procedure
Builder
- New Prop for the comments to add in the New Property
Builder

These General Tab options are:
- Your name and initials which can be referenced in the
comments
- The comment string to be used in the Block Commenter
feature
- Whether to place procedure comments before or after the
Sub/Function line
- How date and time references should be formatted
The other tabs let you specify your comment
structure with the use of tokens to reference the module name,
procedure lists, procedure name, procedure type, your initials,
the current date/time, etc.
Here's an example of the Cleanup Module tab with
the list of Token Definitions displayed. When Code Cleanup adds
this to a module, the #M# token is replaced with that module's
name, #V# is replaced with the list of procedures in the module,
#D# with the current date, and #I# with the developer's
initials.

For the New Procedure tab, there are separate comment structures
for Functions vs. Subs:
Here's more information on the
New Procedure Builder.
Error Handling
Similar to commenting, you can specify your own
error handler to apply to different situations. The Error
Handling section is divided into four tabs.
The first tab is Cleanup Options for Code
Cleanup if you choose to add error handling to procedures that
lack it. Here you can optionally determine if you want to add
error handling to property procedures (Let, Get, and Set), and
determine if you want to update any existing error handling that
is tagged with Total Visual CodeTools comments (or specify your
own tags):
You can specify unique error handling structures for classes,
regular modules, and forms/reports. Here's an example of the
Modules tab showing the error handling text that goes at the top
of the procedure (after comments) and the code at the end of the
procedure:

The error handling text can be customized to be much more
sophisticated to let you pass information such as the module
name #M# and procedure name #P#. The #X# passes Sub or Function
depending on the procedure being updated.
Naming
Conventions
Total Visual CodeTools lets you specify naming
conventions for variables based on their data type and scope. A
powerful option during Code Cleanup is the ability to rename all
the variables in your project to your naming convention.
For instance, you may want all your integers to
start with "int", strings with "str", etc. The use of a variable
naming convention is considered a Best Practice within the
VB6/VBA developer community and helps to quickly read a variable
name and have an idea of what data it contains. Three tabs are
available.
Cleanup Options Tab
The first tab is for general cleanup settings to
determine what variables are updated with your naming
convention. You can include or exclude the members of user
defined types, variables/constants in ALL CAPS, Types and Enums,
and variables shorter than a certain length (for instance one
character variables such as X which are commonly used as
counters).

Data Types
You can specify the variable naming convention
tag you'd like to use for every data type. We've included a
default set of data types and you can add your own:

Variable Scope
In addition to data type, you can also rename
variables to reflect their scope. For instance, global variables
can start with a "g", module level with a "m", procedure
parameters with a "p", etc.

Delivery
Code Delivery just has a few options:

-
How to start and increment line numbering
-
The root letter to use if you're obfuscating
variable names (all the variables get renamed to this plus a
number)
-
Special commenting tags to avoid comment removal (comments that
start with this don't get removed when you select comment
removal)
Manage Settings
The final section is for managing the settings
file. By default, the file is stored in your Application Data
folder. This can be moved to a network folder so your whole team
can share the same settings. You can also add a password to the
file to minimize the ability of others to modify it.

Total Visual CodeTools 2010 stores the settings in a
Microsoft Access database file. Older versions use a
CTS text file. You can import the settings from a
legacy CTS file from here. It will overwrite your
current settings.