Difference between revisions of "Option Explicit"

From HashVB
Jump to: navigation, search
m (Added VB6 header)
(Added good coding practices category)
 
Line 1: Line 1:
 +
[[Category:Good coding practices]]
 
{{VB6}}
 
{{VB6}}
 
This is the single most important line in '''EVERY''' VB application.
 
This is the single most important line in '''EVERY''' VB application.

Latest revision as of 20:09, 22 January 2006

float
 This article is based on Visual Basic 6. Find other Visual Basic 6 articles.

This is the single most important line in EVERY VB application.

This will cause you to do a little bit more work but will save you from lots of very hard to find mistakes.
It does this by forcing you to declare all variables which stops you making typos in names and creating strange and hard to track down logic errors. It also means you think about data types and what is being stored in a variable.

Please note that it needs to be included at the top of every module to be effective. You can force this option on by default by enabling "Require Variable Declaration" under the VB options.