Explicit statement for using variables without declaration in VB.NET

In this article I shows that how you can use any type of variables within the application without declaring it.
  • 1818

The term "Option Explicit" means that you have to define the names of all the variables which you will used in our application.
 

The term "Option Implicit" means you not need to declare the variable just give the name and use it in the application.

Option Explicit define at the top of a module forces every variable to be declared. The features for that we use explicit option are:

  • Spelling errors are identified.
  • Your variables can be properly declared by you.
  • Confusion is avoided if a variable is the same n

The turn off of Explicit option is also said one feature of that by using this you can simply use the variables within the application by just giving the name of variable you not need to declare the variable earlier.

You see in the out of the code given below the students information will shows on console screen and note that all the variables which are used in code they not declared anywhere in the module, So, the option at the top of module  "Option Explicit Off" doing all this fuctionality.

EXAMPLE

    Option Explicit Off
    Module
Module1
        Sub Main()
            StudentName = "MANISH"
            StudentPhoneNumber = "982668997"
            NumberOfStudent = 1
            Console.WriteLine("Number of Students: " & NumberOfStudent)
            Console.WriteLine("Student name: " & StudentName)
            Console.WriteLine("Student phone number: " & StudentPhoneNumber)
            Console.ReadLine()
        End
Sub
    End
Module

OUTPUT


 1.gif


CONCLUSION
 

The option Explicit off shows in this article that whenever you use this option in your application you not need to declare the variables.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.