hello

my problem is simple but i cant solve it.
i have textbox in form1 and i want the value in the textbox equeal to the value in label in form2..how can i do it..

my code sample is:

form1.Text1.Text=form2.Label1.Caption

its not working...

anyone can help?

Recommended Answers

All 9 Replies

I guess you could put your entire project on here as a .zip file.... the code you have there, I see nothing wrong with. It is perfect.

this is my sample program:

There is no caption in the label to retrieve.

commented: Good Response! +10

aha! No Caption Set Yet!

What do you mean no caption?

i want to input data first in the textbox and automatically connect the inputted data in the label.

Private Sub Form_Activate()
Form2.Label1.Caption = Form1.Text1.Text
End Sub

*Point Above*

You were assigning the value of the caption to the textbox, not the other way around. You can do this:

dim x
x = 5

you cannot do this:

dim x
5 = x

These are not interchangeable....It only works the first way. So when you put:

form1.text1.text = form2.label1.caption

you are saying (with no exception) "I want text1 to now contain the data stored in label1".

Give this code in Form1 :-

Private Sub Text1_Change()
Form2.Label1 = Text1.Text
End Sub

commented: thanks... +1

thanks guys for your ideas and time analyzing my problem in visual basic..
thanks to comatose, arvin2006 and ravi kant..

thanks ravi kant...you have the exact solution to my program..

thanks again guys for all your commments..

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.