473,407 Members | 2,312 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,407 software developers and data experts.

Option Strict Off

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.

However I never say never (well perhaps not never :)) and so I would like
to investigate the exceptions to the "Option Strict On" policy.

I would like to get the group's take on when it *is* useful to disable this
and go for "Option Strict Off"

2 parts to this....

1. What situations can you think of where "Option Strict Off" is best because
of clarity of code?
2. What situations can you think of where "Option Strict Off" is best because
the really is no other way to achieve theend result otherwise?

Thanks for any input.

--
Rory
Sep 7 '07 #1
8 2401
A wise man once said: "Never put off until runtime what you can fix at compile
time."
lol - I've never been called a wise man before - thanks for the
compliment!

2. What situations can you think of where "Option Strict Off" is best because
the really is no other way to achieve theend result otherwise?
Latebinding immediately comes to mind, but I think you can suppress
the error message using a method attribute. I'll have to investigate
this further (or hopefully someone else will do it for me and let us
know).

Another reason why a developer might turn off Option Strict is if they
had a class VB conversion project that needed to be completed ASAP.
While this could allow runtime errors to sneak in, it might be a
necessary evil to reach a deadline.

That's about all I can think of at the moment, hopefully others will
share their thoughts.

Thanks,

Seth Rowe

Sep 7 '07 #2
1. IMO none (if clarity doesn't mean shorter for you)

2. Easy late binding (I believe this can be done "explicitely", never
checked this)

Also as this can be set on a file by file basis, even in the later case you
can still use "option strict on" for your project (and have "option strict
off" only for this particular file where you "need" it).
Not tried but you can even perhaps split a class using the partial keywords
to set apart what need option strict off and have the rest of the class
still use your project option strict on default...

---
Patrice

"Rory Becker" <Ro********@newsgroup.nospama écrit dans le message de news:
b0**************************@msnews.microsoft.com...
>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.
However I never say never (well perhaps not never :)) and so I would like
to investigate the exceptions to the "Option Strict On" policy.

I would like to get the group's take on when it *is* useful to disable
this and go for "Option Strict Off"

2 parts to this....
1. What situations can you think of where "Option Strict Off" is best
because of clarity of code?
2. What situations can you think of where "Option Strict Off" is best
because the really is no other way to achieve theend result otherwise?

Thanks for any input.

--
Rory


Sep 7 '07 #3
Rory,

Option Strict off is very good when you are new to VB. Don't spent time with
things that are not direct about the language it self. When you are no more
a newbie it is of course forever on in your standard options and you set it
therefore even anymore in top of your program.

If you really can go on (this happens never to me), than you can always use
Option Strict Off in top of your program.

Just my idea,

Cor
"Rory Becker" <Ro********@newsgroup.nospamschreef in bericht
news:b0**************************@msnews.microsoft .com...
>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.
However I never say never (well perhaps not never :)) and so I would like
to investigate the exceptions to the "Option Strict On" policy.

I would like to get the group's take on when it *is* useful to disable
this and go for "Option Strict Off"

2 parts to this....
1. What situations can you think of where "Option Strict Off" is best
because of clarity of code?
2. What situations can you think of where "Option Strict Off" is best
because the really is no other way to achieve theend result otherwise?

Thanks for any input.

--
Rory

Sep 7 '07 #4
Here a few reasons:

1. A good time to use OPTION STRICT OFF is when converting legacy VB
applications to .NET.

This makes it quicker to get a complex legacy app up and running - and then,
over time, you can back fill until most of all of your code works under
OPTION STRICT ON.

2. Prototyping VB applications. With OPTION STRICT OFF you can whip up
prototypes very quickly.

3. Working with COM. For some COM operations, using OPTIONS STRICT ON will
mean creating a whole lot of extra code - just ask a C# programmer who tries
to work with COM and doesn't have the OPTION STRICT OFF option.

--
Mike

Mike McIntyre [MVP]
http://www.getdotnetcode.com
"Rory Becker" <Ro********@newsgroup.nospamwrote in message
news:b0**************************@msnews.microsoft .com...
>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.
However I never say never (well perhaps not never :)) and so I would like
to investigate the exceptions to the "Option Strict On" policy.

I would like to get the group's take on when it *is* useful to disable
this and go for "Option Strict Off"

2 parts to this....
1. What situations can you think of where "Option Strict Off" is best
because of clarity of code?
2. What situations can you think of where "Option Strict Off" is best
because the really is no other way to achieve theend result otherwise?

Thanks for any input.

--
Rory


Sep 8 '07 #5
1. Never, even when porting VB 6 or VBA code. I use Option Strict On and
fix the type errors. I have had instances where VB 6 programs would crash
for no apparent reason simply because VB 6 was mis-casting a variable.

2. Late Binding would be the only time. In this case I would actually do
the late binding in a small source file with Option Strict Off and lots of
comments explaining the datatypes involved.

Mike.

"Mike McIntyre" <mi****@getdotnetcode.comwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
Here a few reasons:

1. A good time to use OPTION STRICT OFF is when converting legacy VB
applications to .NET.

This makes it quicker to get a complex legacy app up and running - and
then, over time, you can back fill until most of all of your code works
under OPTION STRICT ON.

2. Prototyping VB applications. With OPTION STRICT OFF you can whip up
prototypes very quickly.

3. Working with COM. For some COM operations, using OPTIONS STRICT ON
will mean creating a whole lot of extra code - just ask a C# programmer
who tries to work with COM and doesn't have the OPTION STRICT OFF option.

--
Mike

Mike McIntyre [MVP]
http://www.getdotnetcode.com
"Rory Becker" <Ro********@newsgroup.nospamwrote in message
news:b0**************************@msnews.microsoft .com...
>>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.
However I never say never (well perhaps not never :)) and so I would like
to investigate the exceptions to the "Option Strict On" policy.

I would like to get the group's take on when it *is* useful to disable
this and go for "Option Strict Off"

2 parts to this....
1. What situations can you think of where "Option Strict Off" is best
because of clarity of code?
2. What situations can you think of where "Option Strict Off" is best
because the really is no other way to achieve theend result otherwise?

Thanks for any input.

--
Rory





Sep 9 '07 #6
Hi Rory,

Have you reviewed all the community replies to you? Do they make sense to
you? If you still need any help or have any concern, please feel free to
feedback, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 13 '07 #7
Jeffrey Tan wrote:
>
Have you reviewed all the community replies to you? Do they make sense
to you? If you still need any help or have any concern, please feel
free to feedback, thanks.
Apologies to all. I have been rather busy and have not, until now, found
time to reply

Yes I have read all replies and have found useful information in each.

My conclusion is that there is no valid use (for my purposes) of "Option
Strict Off" which can justify the loss of the extra checks provided by "Option
Strict On"

Hopefully thre answers provided will help others determine if this is the
case in their own scenarios

This has been a useful exercise in checking my own assumptions

My thanks once again to all.
--
Rory
Sep 13 '07 #8
Hi Rory,

Thank you for the confirmation.

Yes, I agree turning on Option Strict should be good for most VB.net
programming. It will help us to find out programming errors at compile-time
instead of delaying to the runtime. This will improve our development
efficiency a lot.

Anyway, if you need further help, please feel free to post, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 14 '07 #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...
11
by: Daylor | last post by:
hi. im using option strict on. im doing in ,from the simple reason ,to be warn when there are implict conversion like string to int ,int to string. BUT. the price ,(now i see ), is very bad....
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...
17
by: David | last post by:
Hi all, I have the following problem: my program works fine, but when I add option strict at the top of the form, the following sub fails with an error that option strict does not allow late...
15
by: guy | last post by:
when i first started using .net (beta 1) i came across option strict and thought hey this could be really good, and since then have always turned it on, most people here seem to agree that this 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"...
18
by: Poldie | last post by:
How do I turn it on? I'm using vb 2005 in visual studio 2005 sp1. In my web.config I have: <compilation debug="true" strict="true" /> In my Tools/Options/Projects and solutions/vb defaults...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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.