Public statement
Define public variables and allocate storage space. Define a private variable in the Class block.
Public varname[([subscripts])][, varname[([subscripts])]] . . .
Parameters
VarName
The name of the variable, followed by the standard variable naming convention.
subscripts
The number of dimensions of the array variable; You can declare up to 60-d arrays. The subscripts parameter uses the following syntax:
Upper [,Upper] ...
The lower bound of an array is always 0.
Description
The public statement variable can be used for all procedures in all scripts.
Before you can use a variable that references an object, you must assign an existing object to the variable with the Set statement. The declared object variable is initialized to Empty before assigning the value.
You can also declare a dynamic array by using the public statement with empty parentheses. After declaring a dynamic array, you can use the ReDim statement within the procedure to define the dimensions and elements of the array. An error occurs if you attempt to declare the dimension of an array variable, and the size of this array variable has been explicitly specified in Private, public, or Dim statements.
The following example illustrates how to use the public statement:
public mynumber ' public Variant variable. Public MyArray (9) ' public array variable. ' multiple public declarations of Variant Variables. public MyNumber, MyVar, yournumber