I would call myself a Visual Basic enthusiast, but by no means do I think of myself as a developer. I know enough to do a few things—but usually just enough to get myself stuck to the point of having to call in a friend who actually is a developer. Even so, I have done enough dabbling in VB and enough development in VBA for Office to know what’s a useful tool and what’s just window dressing. I have also worked in development project management enough to know what developers might find useful, and this article will highlight a product that does a rare thing: it provides value to both enthusiast programmers and developers. Here’s a look at Total Visual CodeTools produced by FMS, Inc.
I got an evaluation version of this product right before I started working on a small project for an application that would perform simple database access to display records in a VB form and allow simple data updating. I took on the project partly as a means of learning how to do it. Most of what I know about VB has been acquired by volunteering to do something I didn’t know.
When I started my research, I didn’t find many things that would show someone like me how to approach accessing a SQL database from VB. Then I remembered that the Total Visual CodeTools marketing materials mentioned something about an ADO/DAO record set builder, so I checked it out. After pointing the builder at a DSN for the database and selecting the table I wanted to access, I had VB code ready to paste into my button-click event. The code would make the connection and debug.print the contents of the fields. From this, I was able to use the debug.print examples to populate text boxes on my form with the output of the record set. With the code generated by the builder, I had a prototype of my application built in about 30 minutes.
This made me curious about the rest of the product, so I started exploring. The whole point of the toolset is to easily enable code standards. The tools include a procedure/function builder that allows users to make sure that every procedure or function they create will contain the same standard comment block and error-handling code. One interesting tool is the Property Procedure Builder, shown in Figure A. It creates the Set, Let, and Get statements in a standard way using the variable names you give it. Listing A shows the code generated by this dialog.
|Property Procedure Builder|
Cleaning up code
How many times has this happened to you: you get handed some code that is just a mess—no indention, no variable naming standards, lots of multiple-statement lines, etc. Total Visual CodeTools includes a feature called Code Cleanup that will help you apply your own predefined standards for such items, as well as for error handling, comment blocks, and other code style issues.
Here is a sample of some code with various problems:
Function TestVars(A As Integer, B As Integer) As Double
Dim dblReturn As Double, x As Integer
dblReturn = 10
If A <= 20 Then
For x = 1 To 20
dblReturn = dblReturn + x ^ B
x = A
x = x + 1: dblReturn = dblReturn + x * B
Loop Until x > A
TestVars = dblReturn
Here is the same code after running Code Cleanup:
Function TestVars(pintA As Integer, pintB As Integer) As Double
‘ Comments :
‘ Parameters: pintA
‘ pintB –
‘ Returns : Double –
‘ Modified :
On Error GoTo PROC_ERR
Dim dblReturn As Double
Dim intX As Integer
dblReturn = 10
If pintA <= 20 Then
For intX = 1 To 20
dblReturn = dblReturn + intX ^ pintB
intX = pintA
intX = intX + 1
dblReturn = dblReturn + intX * pintB
Loop Until intX > pintA
TestVars = dblReturn
As you can see, the second example is going to be easier to work with. Once of the cool things about the tool is that the variable-naming conventions, comment blocks, and error-handling routines are all customizable. You get to decide the standards that are applied. You can even save sets of standards in configuration files so that if you work with clients who require different standards, you can reconfigure how Total Visual CodeTools applies sets of standards.
Another handy feature is the Code Delivery module, which will do things like add line numbers (see Listing B) so that the maintenance programmer will have an easier time debugging your code. On the flip side, you can scramble variable names and remove constants, blank lines, and indentions if you need to make the code you deliver less reusable or readable. Code Delivery will also clean up debug and stop statements you may have been using during the debug process.
After working with Total Visual CodeTools for a while, I’ve come across only one thing I don’t like about it. The code it generates does not use named arguments. But that’s just a matter of personal preference. I like this product. It has helped me write more readable, maintainable code, and it basically taught me ADO database programming. It is very much worth the $299 single-seat price. If you buy it in a five-pack, the price drops to $179 a seat, falling to $119 if you buy a 25-pack. Check out the trial version here and see for yourself.