6. Turn On the Option Strict

One area where bugs often occur in programming is where variables are not typed or values are converted from one type to another. In VB.NET, it is possible to insist that all variables are typed and possible unsafe conversions are documented using DirectCast (or CType). This is done by setting the Option Strict to On.

At http://www.eggheadcafe.com/articles/20030801.asp, it says: ‘Unfortunately, in bringing out the final release of Visual Studio.NET, Microsoft bowed to the cries of millions of VB programmers and left Option Strict Off by default in all our VB.NET projects! Just about every professional author and programmer will tell you that you should ALWAYS set Option Strict to "On"!’

‘Fortunately, there is a very easy way to do this so that you won't forget. You are hereby strongly encouraged to go to the Visual Studio's Tools | Options menu, click the Projects | VB Defaults folder and set Option Strict and Option Explicit to On. You might then spend a bit more time writing CType-s or DirectCast-s, but you will avoid spending much more time tracking down some mysterious runtime errors. Many of your programs will also run FASTER.’

That does not seem to work for projects that you have already created. For such projects, do the following: From the Project menu, choose the last option which is the name of the project followed by the word Properties (e.g., PointClassTest Properties). Then click on Build. Then change the setting of "Option Strict" to "On".