I have two forms as form1 and form2 in my project.in form1 it has textbox as txtid. I take n=txtid.text in from1.then how can I use the same value of n (got at form1) applicable at from2.

Recommended Answers

All 7 Replies

Declare your "n" value in a module -

''In a module...
Dim n As String

''In Form1...
n = Text1.Text

''In Form2...
Text1.Text = n

please if can tel me how to add a module?.as example if I use the value of n as n=5 in form1,then what i want is in form2 also the value of n shold be equal to n=5.when I assign one value to n at form1 then that value of n should be same at form2.please help me to do that.

Click on Project-->Add module

Then add the code I gave you above for module, form 1 form 2 etc...

I did this way.
'in module
dim n as string

'in form1
private sub cmd1_click()
n=txt1.text
form2.show
endsub

'in form2
private sub cmd1_click()
txt1.text=n
endsub

but at form2 the value of n is not given as I assign n at form1.

My bad, sorry. When you declare variables in a module, you have o make it public...

In your module, change the following.

Public n As String

''Dim will only allow values within the module. Public will let you use it in ALL forms and modules.

thank you very much friend.great help.thank you again.

Only a pleasure. Happy coding... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.