Link to home
Start Free TrialLog in
Avatar of mrafanan
mrafanan

asked on

USERFORM Variable

I am using two userforms.

Userform1: Variable1
{ variable1=textbox1}

Userform2:
if variable2=variable1 then....

so basically, i entered a text on userform1, and want to compared this text  to the 2nd form that is entered, it looks like my code cannot compare the first entered text maybe because it is in a different form or not public, how do i make this public so i can compare it to the 2nd form?>?
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Form1:
Public Variable1 as string

Form 2:
If Variable2 = UserForm1.Variable1 then

ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Two other methods:

(1) You could expose a property which is a little safer than opening up a public variable

Dim Variable1 as String

Property Get Var1() as String
   Var1 = Variable1
End Property

then:

If Variable2 = Userform1.GetVar1 Then


or

(2) Create a public variable in a module and have it update whenever the textbox1 is changed. This way, you can have flexibility to unload the form, but the value will remain in the module variable throughout the duration of the project.


Jell


Sorry, (1) should probably read:

Private Variable1 as String