+92 332 4229 857 99ProjectIdeas@Gmail.com

Option Explicit (Vb.net)


Option Explicit
This statement is used to allow or restrict the use of variable without its declaration. By default Option Explicit is On.

·         Option Explicit Off
·         Option Explicit On

Option Explicit On

By setting the Option Explicit to be On, it will restrict the use of a variable without its declaration. It will generate an error when user tries to use a variable without its declaration.

Example

newVar = 10
MsgBox(newVar)

In this case  the complier will generate an error that newVar is not declared because Option Explicit is set to On.

Option Explicit Off

By setting the Option Explicit to be Off, it will allow the use of a variable without its declaration.

Example

newVar = 10
MsgBox (newVar)

In this case the compiler will not generate an error because Option Explicit is set to Off.

0 comments: