Community QBasic

Rebooting the QBasic we all know and love!


Project maintained by Cory Smith

SHARED

Gives a subprogram or function access to module-level variables.

Syntax

SHARED variable[ AS typename] [, variable[ AS typename] ]…

Comments

By default, a subprogram or function has access to a variable only if you pass the variable as a parameter.

variable is the name of the module-level variable to share.

typename is the variable’s type: INTEGER, LONG, SINGLE, [DOUBLE][DOUBLE], STRING, or a user-defined type.

Example

DIM a AS INTEGER
a = 5
CALL Test
END

SUB Test
  SHARED a AS INTEGER
  PRINT "Value of variable A is"; a 
END SUB

See Also