How do I pass variables from a mosule to a userform?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi once again. I am trying to use a standard userform to answer different
questions at different times. My problem is that the values of the variable
in the module are not being passed into the userform code. Is there a way to
accomplish this task?
 
At the top of your module, declare the variables as public, as in:

Public myVariable As String

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Hi once again. I am trying to use a standard userform to answer different
questions at different times. My problem is that the values of the variable
in the module are not being passed into the userform code. Is there a way to
accomplish this task?

Declare the variables as global as David suggests, or for example if your form's
name is frmMyForm and you've declared a variable in the form code MyVar:

frmMyForm.MyVar = "Whatever"

or if there's a textbox on the form:

frmMyForm.txtMyText.Text = "Here's some text"

This will implicitly load the form, by the way, but the form won't become
visible until you .Show it.

And after you hide the form (but before unloading it) you can access the form's
variables and properties:

If frmMyForm.txtMyText.Text = "" Then
MsgBox "You didn't answer my question!!!"
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top