What does this do?Option Explicit?

  • Thread starter Thread starter Guest
  • Start date Start date
ken said:
hi All.

What does this command dot?

Option Explicit

When you specify Option Explicit on, you are obliged to declare all your
variables before using them.
 
ken said:
What does this command dot?

Option Explicit

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
 
Back
Top