View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Public Variables

Declare the public variable in you general module.

Public variables in a class module (such as a userform) have scope within
the form.

You could address it as a property of the form

Userform1.SheetExcludeArray

Also, your current use in Userform2 is working with a different
SheetExcludeArray.

But if you unload the form, it is gone. So better to declare it in your
module.

--
Regards,
Tom Ogilvy

"ExcelMonkey" wrote in message
...
Or is this because public variables do not have the scope
across userforms? That originally I was generating the
array in a sub within userform1 that was creating another
temporary userform(dilaogue sheets). The final sub that
used the array was in a sub that was within userform1.

I have done away with teh dilog sheets and have had to
build a second userform. Is the issue that I actually
popeulate the array in userfor2 but now need to pass it
to userform1 so the sub in userform1 can use it? This is
confusing too becuase I was able to populate the array in
userform 2 without declaring it But the again, I was not
in Option Explict mode either......ummmmmmm.



-----Original Message-----
I have a file with 3 userforms and 1 module. In

userfor1
I have declared a public variable:

Public SheetExcludeArray As Variant

The first part of this form calls userform2 which
populates the array. On userform2 I populate this array
and the Debug.Print tells me the values are present
within the procedcures that support useform2. When I am
finished with this form I Unload it and this takes me
back to userform1. When I complete the rest of

userform1
my main routine is called. The main routine uses teh
values from the array I populated. However the values
are not longer present. Is this becuase I am unloading
the form?

Thanks
.