Results 1 to 3 of 3

Thread: [RESOLVED] By default is option strict on or off

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    Resolved [RESOLVED] By default is option strict on or off

    if i don't specify the state of the "Strict" then is it in the On state or Off state, Or it depends upon the value we specify in the VB Options(Tools Menu).

    Actually i am exporting some data to excel using late binding. I just copied the code specified in FAQ.

    I didnt specify Option strict on or off. And in the VB Options it is set Off.

    I am getting an error as "option strict on disallows late binding".

    If i specify Option Strict Off in the code,then everything is clear.

  2. #2
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: By default is option strict on or off

    by default "option strict" should be set to off but you might have option strict set to on in your project properties

    go to the toolbar > compile and check it there.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: By default is option strict on or off

    There are three places you can set the value of Option Strict: the IDE options, the project properties and the top of a code file. When you first install VS, Option Strict is set to Off in the IDE options. The value set in the IDE options controls the default value in the project properties. When you create a new project, the value for Option Strict will be whatever it is in the IDE options. You can set the value of Option Strict at the top of a code file to affect only that code file, overriding the value in the project properties if it's different. If you don't set it explicitly in a code file then that code file behaves according to the project properties.

    This is what you should do:

    1. Install VS.
    2. Open the IDE options and set Option Strict On, then never change it again.
    3. When you create a new project it will have Option Strict set On, and you should never change it.
    4. On the rare occasions that you need to use late-binding, e.g. Office Automation, set Option Strict Off in only those code files that require it. You should also break your code up such the the absolute minimum of code is in those files, using partial classes if necessary.

    Basically, Option Strict should be On at all times unless you specifically need it Off.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width