What does this do?Option Explicit?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ken

    What does this do?Option Explicit?

    hi All

    What does this command dot

    Option Explicit
  • limint

    #2
    Re: What does this do?Option Explicit?


    "ken" <anonymous@disc ussions.microso ft.com> a écrit dans le message de
    news:CC22D1CB-23E7-4B64-A0F8-31AAA8A29921@mi crosoft.com...[color=blue]
    > hi All.
    >
    > What does this command dot?
    >
    > Option Explicit[/color]

    When you specify Option Explicit on, you are obliged to declare all your
    variables before using them.


    Comment

    • BluDog

      #3
      Re: What does this do?Option Explicit?

      >Option Explicit

      It ensures all variables are declared before you can use them.



      Cheers

      Blu

      Comment

      • Arne Janning

        #4
        Re: What does this do?Option Explicit?

        ken wrote:[color=blue]
        > What does this command dot?
        >
        > Option Explicit[/color]

        Hi ken,

        Option Explicit means that you have to declare your variables before you
        can use them.

        Option Explicit On

        Private Sub Button1_Click(. ..) Handles Button1.Click
        i = 1
        End Sub

        --> Compiler Error. You have to declare i first: Dim i as Integer


        Option Explicit Off

        Private Sub Button1_Click(. ..) Handles Button1.Click
        i = 1
        End Sub

        --> no compiler error.

        There is only one thing to say about Option Explicit Off: do not use it.

        It makes your code less safe and errors will be hard to detect.

        Cheers

        Arne Janning

        Comment

        • Armin Zingler

          #5
          Re: What does this do?Option Explicit?

          "ken" <anonymous@disc ussions.microso ft.com> schrieb[color=blue]
          > hi All.
          >
          > What does this command dot?
          >
          > Option Explicit[/color]

          Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.



          --
          Armin

          How to quote and why:



          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: What does this do?Option Explicit?

            * =?Utf-8?B?a2Vu?= <anonymous@disc ussions.microso ft.com> scripsit:[color=blue]
            > What does this command dot?
            >
            > Option Explicit[/color]

            Place the caret on 'Option Explicit' and press the F1 key.

            --
            Herfried K. Wagner [MVP]
            <URL:http://dotnet.mvps.org/>

            Comment

            Working...