View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
D.Parker D.Parker is offline
external usenet poster
 
Posts: 31
Default Using Public to Pass Variable

I have renamed my variable from Name to XName, for the sake of example.

My Module call my UserForms, so would I place the Public declarations at the
first line of the module? I not clear on the placement of the Public XName
as String declaration?
Thank you.

DP

"Jim Thomlinson" wrote:

Give this a try...

msgbox userform4.Name

Depending where all you have declared a variable called Name you may need to
be more explicit in your reference to Name.

One thing I do if I am going to be requiring Global Variables is to declare
a module strictly for the purpose of storing them. I can then just refer to
them by referencing that module. Keeps things a little straighter if they are
all in one place...

HTH

"D.Parker" wrote:

I have a UserForm that captures the users name, I am trying to pass that
information to another UserForm. I'm assuming that is possible using the
Public declarations, but I am obviously having problems. Here is my example
code

Public Name As String
________________________________
Private Sub OKButton_Click()
Name = NameBox1

UserForm4.Hide
End Sub
________________________________

'Name gets passed to this UserForm

________________________________
Private Sub SignOffButton_Click()
MsgBox Name

Unload UserForm5
End Sub
________________________________

Do I need to declare the variables Public in UserForm5 also? Are they
declared in the right place? Should the subs be name Public instead of
Private? etc. My MsgBox is returning empty. Any help is greatly
appreciated.

DP