Passing variables

is it possible to pass variables from one form to another?
I can't seem to manage it. Any ideas?
SIMONBRATTAsked:
Who is Participating?
 
hessConnect With a Mentor Commented:
yes... use a module and declare your variables as public from within it.
0
 
hessCommented:
if you have a futher questions just post them as comments
0
 
amebaCommented:
Simple way:
Add to your Form1 declarations:
Public CustName As String
Public Points As Long
Public UpdForm As Form

Then you can use:
Form1.CustName="Simon"
Form1.Points=50
Set Form1.UpdForm=FormCU1
Form1.UpdForm.Show

---
Better way is to use Property Get/Let pair of procedures (or Get/Set)
Private m_CustName As String ' declarations

Public Property Get CustName() As String
    CustName=m_CustName
End Property

Public Property Let CustName(ByVal vNewValue As String)
    m_CustName=vNewValue
    Caption = "Customer: " & m_CustName
End Property
0
 
SIMONBRATTAuthor Commented:
Thanks, simple answer i guess but i'm a near beginner
0
 
hessCommented:
in a module add this line
public x as integer

in any other code you can give x a value and all x's will have that value because now x is the same variable in all of you subs and functions
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.