473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Option Strict

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
8 3957
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
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
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
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
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
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
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
>
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
13
by: Cor | last post by:
Hi Option Strict gurus, Because of the so much given advises here to use Option Strict I did try to use that. But it gives an error and I don't know how to resolve that. The message is that...
8
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
3
by: Rich | last post by:
Hello, The following Delegates example works with Option Strict Off, but if I change it to Option Strict On then VB.Net complains about the line dgY = System.Delegate.Combine(dgI, dgA) Is...
13
by: C. Moya | last post by:
I fully expected the lack of a way to set Option Strict globally to be fixed in SP1. I can't seem to figure out if it has been fixed or not. It still seems we have to add the declaration at the top...
1
by: Jerad Rose | last post by:
I believe this issue is specific to ASP.NET. Why does VB.NET (2.0) ignore the project-level setting for Option Strict? I have the setting turned on in web.config: <compilation debug="true"...
0
by: Michael Jenck | last post by:
Hi All, I have been playing with the codedom and can't get it to output for option compare Binary with a CodeCompileUnit. I have searched the web and Don't now if it's possible. If it's not...
8
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the...
8
by: =?Utf-8?B?R3JlZw==?= | last post by:
We have an application in our office that has the Option Strict option set to off right now. I do understand it should be set to ON, but right now, I'm just going to continue with it this way since...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.