Option statments in VB.NET

Discussion in 'Visual Basic [VB]' started by pradeep, Apr 8, 2007.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Option statements in VB.NET

    If you want to properly utilize VB.NET, it is very important to understand option statements. The following is a quick overview of the three option statements that are supported in VB.NET:

    • Option Explicit: By default, Option Explicit is on for VB.NET projects. It's a good programming practice to set Option Explicit on because it helps developers avoid implicitly declaring variables, and thus write better code. This forces developers to explicitly declare variables utilizing the Dim keyword and specifying the data type for the variable.

    • Option Compare: By default, the Option Compare is Binary; however, you can set Option Compare to Text instead.

    • Option Strict: Option Strict Off is the default mode for the code in VB.NET; however, it's preferable to write code with Option Strict on. Option Strict On prevents implicit type conversions by the compiler. It's also a safer way to develop code, which is why most developers prefer it.
    Note: Option Base, which allows you to specify the base of the declared arrays, is supported in VB6 but not in VB.NET.
     
  2. bhavin73

    bhavin73 New Member

    Joined:
    Jun 24, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    [COMMENT]Is this your site?[/COMMENT]
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice