| Start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Declaring and assigning a variable using a primitive type Variables in Visual Basic are declared using the A variable declaration can also include an access modifier (opens new window), such as
As a shorthand, the The supported data types are outlined in the table below:
There also exist data identifier and literal type characters usable in replacement for the textual type and or to force literal type:
The integral suffixes are also usable with hexadecimal (&H) or octal (&O) prefixes: Date(Time) objects can also be defined using literal syntax: Once a variable is declared it will exist within the Scope (opens new window) of the containing type, The counter variable will only exist until the Alternatively, you can use the |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Levels of declaration – Local and Member variables Local variables - Those declared within a procedure (subroutine or function) of a class (or other structure). In this example, The In this example, the console is Member variables - Declared outside of any procedure, at the class (or other structure) level. They may be instance variables, in which each instance of the containing class has its own distinct copy of that variable, or Here, |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example of Access Modifiers In the following example consider you have a solution hosting two projects: ConsoleApplication1 and SampleClassLibrary. The first project will have the classes SampleClass1 and SampleClass2. The second one will have SampleClass3 and SampleClass4. In other words we have two assemblies with two classes each. ConsoleApplication1 has a reference to SampleClassLibrary. See how SampleClass1.MethodA interacts with other classes and methods. SampleClass1.vb: SampleClass2.vb: SampleClass3.vb: SampleClass4.vb: Syntax
|
Read Article
https://develop.horje.com/learn/1434/reference