A variable is a named item that can be used to store values which change over time. You can store a value
in a variable, access its current value or replace it with another value. Variable names consist of an alphabetic
character (a-z) followed by one or more alphanumeric characters together with the underscore character.
Variable names are case insensitive so “ABC”, “Abc” and “abc” all reference the same variable. Variables must
be defined to be a specific Data Type using
the DIM statement before they are used.
Using a variable
Variable contains the same value until it is assigned a new value. Variables are used to manipulate and store values
that vary over time. A real world example of a variable is your Bank Account Balance since it contains a quantity of
money that varies over time. A suitable name for this variable could simply be “BALANCE”. This example demonstrates
how a variable is declared, assigning an initial balance, adding money to the balance, subtracting money from the balance,
and printing the current balance.
DIM BALANCE AS DOUBLE
BALANCE = 1000.0
BALANCE = BALANCE + 100.0
BALANCE = BALANCE - 25.0
The program should print the value 1075.0