Variable Declaration

You declare a variable to specify its name and qualities. You use the statement Dim. Its location and contents give a variable its qualities.

For information on how to make correct names, see Declared Element Names.

Declaration scopes

Local and member variables

A local variable is a variable declared in a procedure. A member variable is a member of a declared type. You declare it in module scope. It can be a member of a class or structure, but not in a procedure internal to that class or structure.

Shared and instance variables

TODO

Declaring data type

The clause As in the declaration statement lets you give the data type or object type of the declared variable. The permitted types follow:

You use the clause In in the declaration statement to declare floating-point variables with a related unit of measure. The expression after In is usually a unit declared with the statement Unit. But it can also be a basic unit declared with Base Unit.

You can declare several variables in one statement with the same data type. But it is not necessary to write the data type more than one time. Some examples follow:

' Declare three integer variables.
Dim i, j, k As Int

' Declare one mass-unit variable and two floating-point variables.
Dim w In kilograms, x, y As Real

Qualities of declared variables

TODO