A variable is a "container" that can store a value, either numerical or string and it can later be changed by the program (as opposed to constants).
All numerical variables defaults to 0 and all string variables defaults to "".
Variables are used to keep track of information that is attained through the program flow, either by user input, calculations or by other ways of communicaton (as with I/O, memory, TCP/IP or files).
Variables in QB64 can be any name except the names of keywords and may not contain spaces or non-alphabetical/non-numerical characters (except "." and "_"), if numerical characters are used in the name at least one alphabetical character has to be used before the numerical character, the same applies to ".", in case a "." is used in the name at least one character has to follow the "." (numerical or alphabetical).
Assigning values to variables can be done by the = assignment symbol (variable1.number = 500, for example).
Arrays is a special usage of variables that can hold many values in one variable by specifying a index enclosed in paranteses.
Example of different usages of variables:
max = 1000 DIM d(max) FOR c = 1 TO max d(c) = c + d(c - 1) NEXT PRINT "Show the result of the addition from 1 to n (1+2+3...+n)" PRINT "n = (0-" + LTRIM$(STR$(max)) + "): "; INPUT "", n IF n <= max AND n >= 0 THEN PRINT d(n) ELSE PRINT "Invalid value (only 0 to" + STR$(max) + " is permitted)."
Show the result of the addition from 1 to n (1+2+3...+n) n = (1-1000): 10 55