What this code is actually supposed to do is display a MessageBox with the greeting "Hello". Since the variable is misspelled and there is no Option Explicit at the top of the code module, you get a blank
MessageBox..!
Now go to the very top of the code module and type the words Option Explicit. Run the program again. What happened..? You get a "Variable not defined" error. This is a simple fix for what could be a complex problem.
Another reason that Option Explicit is so important is because if you do not declare your variables as a specific data type, VB defaults the variable to being type Variant (See data types explained in the next article). A Variant type variable can hold any kind of data from strings, to integers, to long integers, to dates, to currency, etc. Even though this may sound like the best kind of variable to use, it is not. It is the slowest type of variable..! By defining your variables specifically for the kind of values that will be stored in them, will greatly increase your programs performance.
And to make it even easier, how about if I show you how to make VB automatically add Option Explicit to every code module..! It's easy.
Click on the Tools menu and select Options... Now check Require Variable Declaration
Click OK
Now every time you open a new code module the words Option Explicit automatically appear at the top..!