- Avoid keeping an open database connection throughout the execution of your program. Visual Basic was designed to make a connection to a database, perform the interaction and then disconnect. Also, use stored procedures for inserts, updates and deletes because they do not have to be interpreted by the Visual Basic compiler; therefore, they execute much faster and decrease network traffic.
- Handle errors with a try/catch loop. Every function in a program could potentially generate an error; therefore, error handling is essential. Visual Basic 6 programmers typically use the "On Error Goto" method for handling errors. If an error occurs, the code skips to the "Goto" designated area and executes those commands. The try/catch code implemented in Visual Basic 7 (.NET) is noticeably faster than the "Goto" error handling method.
- Turn on "Option Explicit" to force the declaration of variables before they are used and "Option Strict" to prevent the implicit conversions of data types. This forces Visual Basic to perform type validation at compile time and thus increases performance at the time of program execution. Another tip that goes hand in hand with this is to use early binding. Early binding will prevent data type validation and coercion when the program executes, thus creating a faster program.
- Study the .NET Framework and get familiar with all the built-in functions. Visual Basic .NET has a plethora of functions and classes available from the .NET Framework. Don't reinvent the wheel. Make use of this foundation of code that already exists for you.
Database Access
Error Handling
Performance Improvements
.NET Framework
SHARE