From QB64 Wiki
Revision as of 00:59, 2 September 2017 by imported>SMcNeill
Jump to navigation Jump to search

COMMON shares common variable values with other Linked or CHAINed modules.

The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 it has been implemented so that that older code can still be compiled, though it is advisable to use single modules for a single project (not counting $INCLUDE libraries), for ease of sharing and also because the module size constraints no longer exist.

Syntax: COMMON [SHARED] [/blockname/] variablelist

  • COMMON must be called before any executable statements.
  • SHARED makes the variables shared within SUB and FUNCTION procedures within that module.
  • Variablelist is the list of common variables made available separated by commas.
  • Remember to keep the variable type order the same in all modules, as the variables names don't matter.
  • COMMON SHARED is most commonly used to share the variables with subs and functions of that module.
  • Note: Values assigned to shared variables used as procedure call parameters will not be passed to other procedures! The shared variable value MUST be assigned INSIDE of the SUB or FUNCTION procedure to be passed!


  • /blockname/ gives the ability to name a block of variables (ex. COMMON /thename/ a, b, c), this name can later be referenced in the module to only give access to those variables. As such, many COMMON statements can be issued with different names to be shared in different modules. Not supported in QB64.
  • In Qbasic, Common variables can only be passed by CHAIN using compiled modules if BRUN45.EXE is included with the program.
  • Linked files are compiled first and linked with LINK.EXE in QB. QB64 cannot link files.

See also:

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page