Global Array in User Form

  • Thread starter Thread starter Steve Bentley
  • Start date Start date
S

Steve Bentley

Hi All,

I'm having problems understanding how to pass arrays between procedures
in a Form.

I have a UserForm where I have several procedures which are called based
on which command button is clicked. I need to use the same
multi-dimensional array in several procedures. I do not know the right
way to declare an array, initialize the array and make this available to
all the procedures.

I initially tried to place the deceleration of the array at the top of
the form but I receive a "Compile error" which states that arrays are
"not allowed as Public members of object modules".
I then used the Activate event to declare the array and to initialize it
(using a for loop). This sets up the array fine but I can not fathom how
to then access the array afterwards when clicking on a command button
for example.

Also is it correct to place code in a user Form or should this only
really be used for handling events and calling procedures in a module
would be correct practice?

TIA
Steve
 
Declare the array as a public variable at the top of a standard code module.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Back
Top