Difference between revisions of "Option Explicit"
From HashVB
(Why its needed) |
(Added good coding practices category) |
||
(2 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Good coding practices]] | ||
+ | {{VB6}} | ||
This is the single most important line in '''EVERY''' VB application. | This is the single most important line in '''EVERY''' VB application. | ||
Line 5: | Line 7: | ||
Please note that it needs to be included at the top of every module to be effective. | 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 | + | You can force this option on by default by enabling "Require Variable Declaration" under the VB options. |
Latest revision as of 20:09, 22 January 2006
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.