Previous Page

Programming Style

This manual uses the following guidelines in its 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)

 Variable names begin with a lowercase prefix, followed by a lowercase word or words with an initial capital letter. Variables are declared at beginning of an example.

Dim dblIncome as Double
   Dim strFirstName as String * 30

 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

© 1996 Microsoft Corporation. All rights reserved.

Next Page


Casa de Bender