Programming Style

This set of reference manuals uses the following guidelines in Visual Basic code:

  • Visual Basic keywords are in lowercase with an initial capital letter.
    Dim intSomeValue As Integer, strTextValue As String
    Dim intStartNumber As Integer
    ' If, Then, and Str are Visual Basic keywords.
    If intSomeValue = 0 Then strTextValue = Str(intStartNumber)
  • Line labels are used instead of line numbers for error-handling routines and for On...GoSub and On...GoTo statements.
    On Error GoTo ErrorHandler
        .
        .
        .
    ErrorHandler:
        MsgBox Err.Description
  • An apostrophe ( ' ) introduces a comment.
    ' This is a comment; these two lines
    ' are ignored when the program is running.
  • Control-flow blocks and statements in Sub and Function procedures are indented.
    Sub SomeCode ( )
        If intX > 0 Then
            intP = intQ
        End If
    End Sub