By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,475 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Using Option Strict

P: n/a
I've always used Option Strict in my code. However, I was wondering if it
is really necessary. Coding seems a lot easier when you don't use it, but
does it really make a difference? What are the advantages of having Option
Strict set to on? Are there situations were you could run into big problems
leaving it off?
Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Clark,

When you use Option Strict Off you use often late binding. When that cannot
be done you get an error.

As well important it is that you can compare
C++ (6) was much faster than VB6
C# is much faster than VBNet with Option Strict Off
C# has the same performance as VBNet with Option Strict On.

Makes that sense?

Cor
Nov 20 '05 #2

P: n/a
Clark,
Coding seems a lot easier when you don't use it, but
does it really make a difference? What are the advantages of having Option
Strict set to on?


The big advantage with strict typing is that more errors can be found
at compile time.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #3

P: n/a
Okay, thanks. That makes sense.

When you start a new WinForms project, is there a way to have Option Strict
automatically set to on by default just like Option Explicit is On by
default?

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
Clark,

When you use Option Strict Off you use often late binding. When that cannot be done you get an error.

As well important it is that you can compare
C++ (6) was much faster than VB6
C# is much faster than VBNet with Option Strict Off
C# has the same performance as VBNet with Option Strict On.

Makes that sense?

Cor

Nov 20 '05 #4

P: n/a
For the reasons mentioned in the previous responses to your post, some
people call Option Strict the "Good Programmer Switch".

Regards,
Tom Dacon
Dacon Software Consulting

"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:rv****************@twister.nyroc.rr.com...
I've always used Option Strict in my code. However, I was wondering if it
is really necessary. Coding seems a lot easier when you don't use it, but
does it really make a difference? What are the advantages of having Option Strict set to on? Are there situations were you could run into big problems leaving it off?

Nov 20 '05 #5

P: n/a
A global setting for this is located under Tools->Options->Projects->VB
Defaults.

Brian Davis
http://www.knowdotnet.com

"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:kb*******************@twister.nyroc.rr.com...
Okay, thanks. That makes sense.

When you start a new WinForms project, is there a way to have Option Strict automatically set to on by default just like Option Explicit is On by
default?

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
Clark,

When you use Option Strict Off you use often late binding. When that

cannot
be done you get an error.

As well important it is that you can compare
C++ (6) was much faster than VB6
C# is much faster than VBNet with Option Strict Off
C# has the same performance as VBNet with Option Strict On.

Makes that sense?

Cor


Nov 20 '05 #6

P: n/a
Thanks. That's exactly what I was looking for.

"Brian Davis" <br***@knowdotnet.nospam.com> wrote in message
news:eS**************@TK2MSFTNGP09.phx.gbl...
A global setting for this is located under Tools->Options->Projects->VB
Defaults.

Brian Davis
http://www.knowdotnet.com

"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:kb*******************@twister.nyroc.rr.com...
Okay, thanks. That makes sense.

When you start a new WinForms project, is there a way to have Option

Strict
automatically set to on by default just like Option Explicit is On by
default?

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
Clark,

When you use Option Strict Off you use often late binding. When that

cannot
be done you get an error.

As well important it is that you can compare
C++ (6) was much faster than VB6
C# is much faster than VBNet with Option Strict Off
C# has the same performance as VBNet with Option Strict On.

Makes that sense?

Cor



Nov 20 '05 #7

P: n/a
Further to the response below, note that this does not insert Option Strict
into your source code. It simply establishes the default for code modules
where the setting is not explicitly set. The setting can still be overridden
in each code module.

I prefer to explicitly type it at the top of each module (as well as have
the default set), and then there is no danger of having the wrong setting.

HTH

Charles
"Brian Davis" <br***@knowdotnet.nospam.com> wrote in message
news:eS**************@TK2MSFTNGP09.phx.gbl...
A global setting for this is located under Tools->Options->Projects->VB
Defaults.

Brian Davis
http://www.knowdotnet.com

"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:kb*******************@twister.nyroc.rr.com...
Okay, thanks. That makes sense.

When you start a new WinForms project, is there a way to have Option

Strict
automatically set to on by default just like Option Explicit is On by
default?

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
Clark,

When you use Option Strict Off you use often late binding. When that

cannot
be done you get an error.

As well important it is that you can compare
C++ (6) was much faster than VB6
C# is much faster than VBNet with Option Strict Off
C# has the same performance as VBNet with Option Strict On.

Makes that sense?

Cor



Nov 20 '05 #8

P: n/a
>
I prefer to explicitly type it at the top of each module (as well as have
the default set), and then there is no danger of having the wrong setting.


I would prefer when that would matter to set them explicitly off.
That shows direct that it is not by accident.

Just to give a different opinion.

Cor
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.