Enterprise Edition only
Problem auto-fix can automatically fix the problems listed below. Problems that are not in the list require a manual fix. Auto-fix also helps you with the manual fixes by creating specially formatted comments in the code.
You can select which problems you wish to auto-fix, which ones you wish to fix manually, and which ones you wish to ignore. See Auto-fix options.
Dead procedure/declaration/event. A procedure, Declare or Event statement is not used. Auto-fix removes them. Choose the Fix & comment option to comment out dead code, and Fix quietly to remove it altogether.
Dead procedure/declaration/event (called by dead only). A procedure, Declare or Event statement is effectively dead, but it is still called by other dead procedures. Removed in the manner described above.
Event not raised. An event does not fire. Automatic removal is not done. Auto-fix creates a comment for you to consider whether this event needs to be fired or deleted.
Dead variable/constant. A variable or constant is not used. Auto-fix removes or comments out dead variables and constants, as above.
Variable written only. Automatic removal not possible. Auto-fix creates a comment for manual treatment.
Dead type/enum. Auto-fix creates a comment for manual removal.
Unused file. Auto-fix creates a comment for manual removal of file.
Variable/function missing type. A function has no return type definition, or a variable has no type definition. Auto-fix makes the type declaration explicit. By default, the type is Variant in VB 3-6 and Object in VB.NET. If you have used the DefType statement, another type may be added. Warning: Variant/Object is not an optimal data type in most cases. It is slower, uses more memory, and leads to late binding when accessing procedures or other members of an object. You may wish to use manual fix for this problem type, and write in the correct type by yourself.
Dollar would increase performance. Adding $ at the end of a function would increase the speed of execution. Certain functions, like Left, Mid and Right return a Variant that contains a String. The corresponding functions Left$, Mid$ and Right$ return a String. Using the String version makes your program run faster. This rule applies to VB 3-6 code. In VB.NET, there is no performance difference. Auto-fix adds the $ for you in VB 3-6 projects. Warning: VB 3-6 database applications often use the $-less versions for Null propagation. The $ versions don't support Null propagation and will cause a run-time error if given a Null parameter. If you suspect that Null parameter might be given to these functions, use manual fix. This use of Null is not possible in .NET.
Literal "" found. The string literal "" is present in your code. If the statement is an assignment, use vbNullString instead of "". vbNullString is a special constant, available in VB4 and later, that saves memory, speeds up the assignment and later processing of the value. Auto-fix replaces "" with vbNullString.
Note: If the literal "" is used in comparison ( = "" or < > "" ), manual fix is required. The fastest way is to use Len( ) = 0 and Len( ) <> 0 to test for an empty and a non-empty string, respectively. In VB 4-6, use the LenB function instead of Len for the same purpose with extra performance. In VB3 and VB.NET, use the Len function.
Option Explicit missing. A module is missing its Option Explicit statement. You should always use Option Explicit. Using it makes VB require declaration of all variables. This way you avoid using unnecessary implicit Variants/Objects. Even better, you get rid of some nasty errors caused by typing errors and variables with similar names.
Auto-fix adds Option Explicit (On) to all files where it is missing. However, this alone will not deal with all the issues. When you load the project into VB, you will find many undeclared variables which you will have to declare manually before your program compiles. This particular auto-fix is available only when you select both auto-fix and the manual alert ($) option, as you're likely to run into alerts from the VB compiler.
In VB6, you may use Aivosto VB Friend (not included with Project Analyzer). This add-in has an assistant to quickly add missing variable declarations.
Option Strict missing. Auto-fix adds Option Strict On to all files where it is missing. When you load the project into VB.NET, it will most probably complain about implicit type conversions and missing data types. You will have to check these lines before your program compiles. This particular auto-fix is available only when you select both auto-fix and the manual alert ($) option, as you're likely to run into alerts from the VB compiler.
Function with type character. A function is declared ending in one of the old-style $#%!&@ characters. Auto-fix replaces the type character with an As Type declaration. Only the function declarations are auto-fixed — function calls are not modified. The calls will continue to work normally.
Variable/parameter with type character. A variable or procedure parameter is declared ending in one of the old-style $#%!&@ characters. Auto-fix replaces the type character with an As Type declaration. Only the variable declarations are auto-fixed — any references to the variables or parameters are not modified. They will continue to work normally.
Excess scope. A part of your program is accessible from other modules. However, other modules don't use it. Check to see if you should declare the part as Private instead of Public. It is good programming practice to use as tight a scope as possible to prevent other parts of the program calling and modifying parts that they shouldn't have anything to do with. Auto-fix creates a comment with instructions on what to change and where to move the declaration, if required.
Scope declaration missing. A part of your program does not have a defined scope. Instead, it is using a default scope as given by VB. VB's default rules are somewhat complicated and may lead to excess or too narrow a scope. With a narrow scope, you can encapsulate functionality and data. With a large scope, you give access to this part of your program from other parts. Determine which scope is appropriate and declare it explicitly. The current default scope is given. Auto-fix adds explicit scope declaration according to VB's default rules.
Exception: If a declaration has both "Excess scope" and "Scope declaration missing", auto-fix will create a comment for manual treatment. In this case, consider which scope is the best one and add it manually.
Encapsulate non-private variable as property. Variables that aren't declared as Private should be avoided in classes. Read/Write access to a class's member variables should only be allowed via properties. Make the variable Private and add a property to read/write the contents. Auto-fix renames the variable, turns it to Private and makes a set of Property Get/Set/Let declarations to access the variable's contents.
Warning Passed ByRef. Encapsulated Property will not receive changes back from ByRef. In classic VB, passing a variable ByRef may change the value of the variable. Passing a Property ByRef will not change the value, however. This can lead to errors that are hard to debug. When you encapsulate a variable as a property, make sure the logic still functions with ByRef calls. Project Analyzer detects ByRef passing and shows the warning text for the problem. This is not an issue with VB.NET because VB.NET uses copy-in/copy-out semantics for Properties passed ByRef, so variables and encapsulated properties work the same.
Automatic encapsulation works for most variables but not all. First of all, it is dependent on the underlying data type and is enabled only if it is known to be a scalar type or an object type. Automatic encapsulation doesn't work for arrays or variables used as a For index variable. It doesn't work for variables passed ByRef either. In these cases you will need to manually encapsulate the data or leave the code unchanged.
Global found, use Public. Use of Global is outdated. Simply replace Global with Public. VB3 supports only Global. VB 4-6 support Global but favor Public. VB.NET no longer supports Global but requires Public. Auto-fix replaces Global with Public in VB 4-6 projects.
Multiple statements on one line. There are more than one statement on a single line, separated with a colon ( : ). To make your program more readable, auto-fix splits the statements to separate lines.
Single-line If..Then statement found. An If..Then(..Else) construct is on a single line. To make your program more readable, auto-fix splits the construct to multiple lines and adds indentation.
To fine-tune indentation according to your own standards, use the add-in Aivosto VB Friend (available for VB6, not included with Project Analyzer).
Call statement found. The Call statement is no longer needed. Auto-fix removes it.
NameCheck. A name fails Project NameCheck. Auto-fix creates a comment and suggests a new name.
Error handler missing. A procedure has no error handler. Your program may crash if a run-time error occurs in this procedure. You can ignore this problem in procedures with less than or equal to x lines of code. Write x in the "Ignore when" textbox in Problem Options. Sub/Function and End Sub/Function lines are counted as code, making an empty procedure or property block have 2 lines. Leave the box empty if you don't wish to have a limit. Auto-fix creates a comment in procedures requiring an error handler. Consider using Aivosto VB Watch, a tool that ensures proper error handling.
Delayed error handler. A procedure uses delayed error handling (On Error Resume Next, Try without Catch). Run-time errors are handled in the procedure(s) that call this one. This may be completely as you planned, or you may have forgotten to add an error handler (On Error Goto, or Catch in a Try..End Try block). You can ignore this problem in procedures with less than or equal to x lines of code. Write x in the ""Ignore when"" textbox in Problem Options. Sub and End Sub lines are counted as code, making an empty procedure or property block have 2 lines. Leave the box empty for no limit. Auto-fix creates a comment in procedures requiring an error handler. Consider using Aivosto VB Watch, a tool that ensures proper error handling.
Resizable Form missing Form_Resize. The Form_Resize event is missing from a Form that users can resize at run-time. Your application may look odd if you don't respond to Resize events. Auto-fix inserts an empty Form_Resize event and creates a comment, so you remember to implement it. This feature is available for VB 3-6.
Error event missing. Every Data control should have the Error event implemented. If you don't do it, Visual Basic only displays a simple error message. Auto-fix inserts an empty Error event and creates a comment, so you remember to implement it. This feature is available for VB 3-6.
Click event missing. A CommandButton or menu item does not do anything when clicked. Auto-fix inserts an empty Click event and creates a comment, so you remember to implement it. This feature is available for VB 3-6.
Timer event missing. A Timer does not fire an event at defined intervals. Auto-fix inserts an empty Timer event and creates a comment, so you remember to implement it. This feature is available for VB 3-6.
All other problems are handled as manual fix by adding a comment.
©Aivosto Oy - Project Analyzer Help Contents