Summary


Two of the most important things you control with a variable declaration are its data type and its visibility. Visibility combines scope (the piece of code that contains the variable such as a For loop, subroutine, or module), accessibility (the code that is allowed to access the variable determined by keywords such as Private, Public, and Friend), and lifetime (when the variable has been created and not yet destroyed).

To avoid confusion, always explicitly declare the data type and use the most limited scope possible for the variable’s purpose. Turn Option Explicit and Option Strict on to allow the IDE to help you spot potential scope and type errors before they become a problem.

Parameters, property procedures, and constants have similar data type and scope issues. Once you become comfortable with variable declarations, these should give you little trouble.

One of the most important steps you can take to make your code easier to debug and maintain is to make your code consistent. A good naming convention can help. Review the guidelines used by Microsoft Consulting Service, and adopt the pieces that make the most sense to you.

When you know how to declare variables, you are ready to learn how to combine them. Chapter 5 explains the symbols (such as +, -, and ^) that you can use to combine variables to produce new results.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net