When creating a new VB project, Visual Studio will automatically
put Option Strict Off. What is Option Strict and why should it
be on? Having Option Strict ] set to Off is VERY dangerous
because it allows you to implicitly convert types to other
types. Take for example the following code: Dim numeric As
Integer = "1" Dim otherNumeric As Integer = "Hello" The first
assignment of a to an Integer will succeed. The second will fail
miserably... At run time! Because Option Strict is Off, Visual
Studio will not give an error on these types of conversions.
Option Strict On however DOES prevent this sort of thing. The
only way the above code would pass when having Option Strict On
is by explicitly casting, like follows: Dim numeric As Integer =
CType("1", Integer) Dim otherNumeric As Integer = CType("Hello",
Integer) This will still generate an error at run time, but at
least the programmer has been made very aware at design time
that this case might go wrong! Having Option Strict Off is a sin
punished by run time cr