Variables store values during a program execution. Variables are place holders in which you can leave and recall them. A variable has a name and a value.
For Example: Value=0.35
VARIABLE NAMING CONVENTION
When declearing variables we should be aware of a few naming convention that are
i. Must being with a leter.
ii. Must not exceed with 255 characters.
iii. Must be unique.
TYPES OF VARIABLES
Visual Basic recognizing six types of variables.
Numeric Variable includes following numeric data type.
2. Single floating points.
3. Double floating point.
Double floating point
Store integers value from -32768 to 32768
Store integers in the ranges of -2147, 483, 648 to 2147, 483. 648.
Double floating points numbers can represent both negative and positive number in a large range.
The string data types store only text and string variables are decleared with the string type for example: Dim A-ds string A= “Ayesha”.
Boolean data types store True/False values. Visual Basic Allocates two bits to this data type non “O” value is consider True.
For example: Label1.visible=T
Data and time values are store intermaly in a special formit Visual Basic many objects and you can use an object variable to excess the actual object.
In object variable decleared as variant is handel by Visual Basic according to the variable’s current contexts variant can also hold different data types.
For example: Dim my name As variant.
Variables have the values your program assignes to them. Before any value assigens to them, Numeric values are “O” and string variable length. There for we have four special values (Empty, Nothing, Null, Error).
If a variable is decleared in a program but not been assigens a value, the value is empty.
The nothing value is used with objects and indicates that an object variable has not been initialized.
Null is commonly use in data bases. It indicates that the field does not contain data or value or the data variable has not been a assigen the value for the null value.
It allows you two describe a function that returns an error if it accurs in a program.
Some variables not change values during the execution of a program. These are the constants that appears many time in the code.
For example: Pi=3.1412….
If we have to calculate different parameters then we have to define a constant of Pi, for using it many time the code.