By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,988 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,988 IT Pros & Developers. It's quick & easy.

Transfer variable to other form

P: 89
Hi all,
I have a problem to transfer variable from one Form to other Form, such as

Form1:
command_button1()
dim a as string
a="Hello world!"
Form2.show()


I want to see the "Hello World!" on Form2 after pressing command button1 on Form1

Thx advance for for help, Shaif
Dec 21 '07 #1
Share this Question
Share on Google+
9 Replies


debasisdas
Expert 5K+
P: 8,127
Instead of declaring the vaibale in the form1 ,decalre that in a module (.bas file) and access from form2.
Dec 21 '07 #2

P: 89
Hello, Thx for that, I am soory that i cant understand that how i will do that , I am .bat file in module,

Actually i have a value which is calculating on Form1 and i would like to send it to Form2, if possible please give me bit more idea to solve this problem, Thx again, Shaif
Dec 21 '07 #3

debasisdas
Expert 5K+
P: 8,127
try like this

in the module (BAS file)
public a as string

in form1

Expand|Select|Wrap|Line Numbers
  1. command1_click()
  2. a="Hello world"
  3. form1.hide
  4. form2.show
  5. form2.text1.text=a
  6.  
Dec 21 '07 #4

P: 89
Sorry, I tried it could not work, Thx
Dec 21 '07 #5

P: 89
Hi, Sorry I tried again, I worked,,,, Thx a lot, thx thx.
Dec 21 '07 #6

Ali Rizwan
100+
P: 927
Hi all,
I have a problem to transfer variable from one Form to other Form, such as

Form1:
command_button1()
dim a as string
a="Hello world!"
Form2.show()


I want to see the "Hello World!" on Form2 after pressing command button1 on Form1

Thx advance for for help, Shaif
Declare the variable in a module like

Expand|Select|Wrap|Line Numbers
  1. Public a As String
now u can use and modify variable a in any form.

Regards

>> ALI <<
Dec 21 '07 #7

vdraceil
100+
P: 236
Did u try defining the variable as 'public' as Ali advised?
i got a doubt..is public variables declared on a form accessible by all other forms in that project?
i ask this because till now i've declared public variables in modules!!
Dec 23 '07 #8

vdraceil
100+
P: 236
Another possibility is using the 'tag' property of the form.

[PHP]Private Sub Command1_Click()
...
form1.tag=a
form2.show
End Sub

Private Sub Form2_Load()
text1.text=form1.tag
End Sub[/PHP]

U can store the value of 'a' in any control's tag property and refer it accordingly in form2.

All the best
Dec 23 '07 #9

Ali Rizwan
100+
P: 927
Did u try defining the variable as 'public' as Ali advised?
i got a doubt..is public variables declared on a form accessible by all other forms in that project?
i ask this because till now i've declared public variables in modules!!
When u declared a variable with public u can use it any where in a project.
But when it is Private then u can use it only in the form where it defines.
Same case with Dim.

Regards

>> ALI <<
Dec 23 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.