Am 03.06.2010 14:29, schrieb Andy B.:
What exactly does option strict do and what is the best setting for it?
Serious question? Did you read Cor's message?
With Option Strict Off you can write
Dim i As Integer = "wrong setting for option strict"
and the compiler does not even complain. Does this make sense? No.
With Option Strict Off, additional code to convert data is created.
The problem is that one doesn't have an overview of where such
conversions are created.
Consequently you don't know if all conversions are intended.
Consequently you don't know if all conversions will always
succeed and will be done in the intended way.
Consequently you are creating a time bomb.
With Option Strict Off you enable late binding:
Dim o As Object
'...
Debug.Print(o.ToStrig)
You see the fault? The compiler doesn't! Checks are turned off
or postponed to run time. There are few situations where
late binding is required, but that's (usually) not daily business.
Can be useful for Office automation.
Questions answered? First thing done here after installation
is changing the project defaults options to Option Strict On.
It's a shame for MSFT they don't set it by default (once again
in VB 2010 IIRC). It's just an additional potential risk.