Variables

A variable is temporary storage space for numbers, text, and objects. Variables are constantly being created and destroyed and will not hold any values after your program has ended. If you want to save the values of variables or other data. Before allocating storage space for a variable, decide what the variable's lifetime will be. At the same time declares what type of data it is.


 * Types of variables**

"dim number as integer" Will store the data as a non decimal number "dim word as string" Will store data as a word "dim number as decimal" Will store number as a decimal number


 * Variable Declaration**


 * Global Variables**

Are variables are variables that are declared right at the start of of the program and can be used any where in the program. Using global variables is considered bad programming practice, as it is often difficult to track down which part of the code is changing that variable when errors occur.


 * Local Variables**

Variables that can only be used inside the sub they where declared in but can be moved in to other subs if you tell the program to (byref, byval). Putting variables inside sub-routines //protects// them by limiting the amount of code that can alter them. It is therefore easier to find the source of errors.


 * Constants**

A constant is a variable with a non changing value. Constants are used for values that you know will not change. E.g. the value of pi or a file name. They are declared using the "const" keyword.

"**Const** number as integer = 10"