Some Specifics
Follow these guidelines when you write code:
-
Define all variables explicitly. Checking the Require Variable Declaration option under Tools/Options/Editor enforces this. Define variable-length arrays explicitly. (Visual Basic will not enforce this.)
-
Always specify the upper and lower bounds in an array definition.
-
Define constants, and use them in place of numbers in the code.
-
Always use the ByVal and ByRef keywords in parameter lists. Use ByVal where you have a choice.
-
Always use the Private keyword on functions and subroutines that are not exported from a module.
-
Define the types of all variables and function and subroutine parameters explicitly. For example, use Dim nBufSize As Integer instead of Dim nBufSize, and use Function nGetChars(nBufSize As Integer) As Integer instead of Function nGetChars(nBufSize).
-
Do not use implicit type suffixes (such as ! and &) in variable definitions.
-
In For loops, use Next <Index> instead of just Next.