locked
For forum user Chi Ariq and anyone else about OPTION STRICT ON or OFF? RRS feed

All replies

  • That explains a lot. but is it on or off by default? 

    Thanx a bunch John!
    Friday, October 3, 2008 7:32 AM
  • Chi Afriq said:

    That explains a lot. but is it on or off by default? 

    Thanx a bunch John!



    Hi,

    It is OFF by default.

    From the PROJECT menu select PROPERTIES at the bottom and then click on the COMPILE tab.

    In the next screen you will see ComboBoxes to toggle each of the above OPTIONs.


    Regards,

    John

    For links to VB.Net tutorials see here.>> http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/29f2179b-997b-4115-a96d-a0834853b835
    Friday, October 3, 2008 11:54 AM
  • For new projects, I believe the following settings should be applied:

    Option Explicit On
    Option Strict On
    Option Infer Off

    The new Option Infer is cool and all, and is a really great tool when migrating old code (VB6), but it pushes us back into those old VB6 habits which got people into trouble in the first place: defining a variable without a type, expecting it to be one thing when in fact it's another.

    For beginner programmers, the above options should be set (indeed, I don't use Infer On in any new 2008 projects). Explicitly typing variables is a good habit to get into. When you are comfortable doing that, and can't see a reason not to, then you can start not explicitly declaring variables.

    Personally, I see it as another tool to keep good programmers busy and poor programmers...poor.

    (This all refers to VB, and not C#, which has a completely different set of rules).

    Stephen J Whiteley
    Friday, October 3, 2008 3:27 PM
    Moderator
  • Hi ALL,

    Please also see this thread.>>

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/5ecdf8e2-4e1f-4739-8bd1-7ddf5984bd90/


    Regards,

    John

    For links to VB.Net tutorials see here.>> http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/29f2179b-997b-4115-a96d-a0834853b835
    Monday, November 10, 2008 7:20 AM
  • I can only agree: I was right before while searching particular errors in my string library, so I first in my life switched Strict On, as I supposed it turned a light not only at type conversions, but mostly on better not speak errors. For example without at least checking your code with Strict On, it is possible to compile code which calls mistakenly function Replace($, $, $, $, $) instead Replace($, $, %, %, [%]) ... simply because Strict Off will accept $$$ instead %%% arguments as automatically convertible... it is 350kB of code which I considered as very clear.. I found at least 10-20 deep malfunctions, not talking about tons of ugly code, which I wrote with "sense" to be efficient ... but only with Option Strict it is clear, that vbCr nor " " is part of readonly property returning Char Array for so told efficient algorithms... without it, every char array declared can procede lot of reTyping for each member, even if it seems to be pretty good char array :) Anyway I like it... it is good bug flashlight...
    Monday, November 10, 2008 11:20 AM