ðH geocities.com /Baja/Dunes/7592/vbcc5.htm geocities.com/Baja/Dunes/7592/vbcc5.htm .delayed x MÔJ ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ °oÙ ; OK text/html °h ; ÿÿÿÿ b‰.H Fri, 10 Jul 1998 01:16:18 GMT ‚ Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98) en, * MÔJ ;
Visual Basic Naming Conventions
Page 5
Previous Page
|
Home Page
|
VB Page
|
Next Page
Some Specifics
Follow these guidelines when writing your code.
- Define all variables explicitly. Option Explicit enforces this,
and you can force Option Explicit in all objects by checking the
Require Variable Declaration under the menu Tools>Options>Editor.
- Always specify the upper and lower bounds in an array definition.
- Define constants, and use them in place of hard-coded numbers in your code.
- Always use the ByVal and ByRef keywords in the parameter lists of your
subroutines and functions. You should generally not use ByRef at all (see
Changing Your Approach on previous web page)
- Always use the Private keyword on functions and subroutines that are not
used outside of a module.
- Declare all variables explicitly. Dimensioned variables are variant if no
type is supplied but you should always supply a type, even if that type is
variant (e.g Dim nX As Integer, Dim vThing as Variant). This also applies
to subroutines and functions. Such as Function sTest () as String
instead of Function sTest().
- Do not use implicit type suffixes such as ! and & in variable definitions.
- In For loops, use Next instead of just next.
Documentation
One of the best sources of documentation is the code itself. If you follow
specific coding standards throughout your application and thoroughly comment
your code, you are making your program more readable and providing valuable
information to yourself and to other programmers that might have to make
modifications later.
Formatting
Follow these rules when formatting your code:
- Indent your code to 4 spaces. This setting is available in the code
settings sections available through the menu Tools>Options>Editor.
- Punctuate your code with blank lines.
- Keep your procedures to a manageable size, preferably not more than a
single screen.
- Keep your indentation under control, if you are having difficulty remaining
within the right margin, you are probably nesting too deeply.
- Use Parenthesis to enhance the readability of your code. People should be
able to tell what a given formula does at first glance.
End-of-Line Comments
End-of-Line comments should be used to annotate variable and constant definitions.
Dim nX As Integer ' used to index record counting loop
Page 5
Previous Page
|
Home Page
|
VB Page
|
Next Page