Wednesday, June 15, 2011

Naming Conventions

Do not name your local variables or subroutine arguments the same as your module level variables.

i.e.

Sad Code:

Private MyVar As Integer
Public Sub MySub(ByVal MyVar As Integer) Also Sad Code: Public Sub MySub() Dim MyVar As Integer


Tip: Use a character prefix to define the scope and type of your variables.

Happy Code:

Private mnVar As Integer

Public Sub MySub(ByVal vnVar As Integer)
 Dim nVar As Integer