Option Explicit

From HashVB
Jump to: navigation, search
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.