473,624 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3975
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**********@p lanet.nl> wrote in message
news:Od******** ******@TK2MSFTN GP11.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*********@ho tmail.com> wrote in message
news:rv******** ********@twiste r.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*********@ho tmail.com> wrote in message
news:kb******** ***********@twi ster.nyroc.rr.c om...
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**********@p lanet.nl> wrote in message
news:Od******** ******@TK2MSFTN GP11.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***@knowdotn et.nospam.com> wrote in message
news:eS******** ******@TK2MSFTN GP09.phx.gbl...
A global setting for this is located under Tools->Options->Projects->VB
Defaults.

Brian Davis
http://www.knowdotnet.com

"Clark Stevens" <cy*********@ho tmail.com> wrote in message
news:kb******** ***********@twi ster.nyroc.rr.c om...
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**********@p lanet.nl> wrote in message
news:Od******** ******@TK2MSFTN GP11.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***@knowdotn et.nospam.com> wrote in message
news:eS******** ******@TK2MSFTN GP09.phx.gbl...
A global setting for this is located under Tools->Options->Projects->VB
Defaults.

Brian Davis
http://www.knowdotnet.com

"Clark Stevens" <cy*********@ho tmail.com> wrote in message
news:kb******** ***********@twi ster.nyroc.rr.c om...
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**********@p lanet.nl> wrote in message
news:Od******** ******@TK2MSFTN GP11.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
2132
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 about Option Strict? What advantages do I get with Option Strict On? Does better type statement make my code run faster? If anyone knows THE ANSWERS! please fill me in. I have ideas and belief but I would once and for all like to know what the...
13
3247
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 Option Strict disallowes late binding. So how to do it then? The statement is from an example somewhere on MSDN (And don't ask why I use the Ax version from SHDOC, that is just because it has more methods) \\\\\\\\\\\\\
8
1823
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 record in a sql Server view) .... Dim entry As Domino.NotesViewEntry Dim obj As Object str1 = entry.ColumnValues(0)
3
1601
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 there a way to use the Combine method of Delegates in VB.Net with Option Strict On?
13
2314
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 of each and every single code module. Am I missing something here? -- -C. Moya www.cmoya.com
1
3132
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" strict="true" explicit="true" urlLinePragmas="true"/> And also in the preferences:
0
1327
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 possible I just go with CodeSnippetCompileUnit Please email me a copy at: programmer @ jenck . net (remove the extra spaces)
8
2418
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 man in question, in "Option Strict On" by default. Actually I don't believe I have code where this is not the case.
8
3883
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 I do not have the time to fix everything to set it to ON. Anyway, my question is if its set to OFF why is it it keeps getting set back to ON, everytime we move the package from one machine to another. It's the Option Strict option specific to...
0
8238
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8174
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8624
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.