943,563 Members | Top Members by Rank

Ad:
Feb 17th, 2009
0

textbox to label

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dollmar is offline Offline
16 posts
since Feb 2009
Feb 17th, 2009
0

Re: textbox to label

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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 17th, 2009
0

Re: textbox to label

this is my sample program:
Attached Files
File Type: zip sample.zip (2.7 KB, 29 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dollmar is offline Offline
16 posts
since Feb 2009
Feb 17th, 2009
1

Re: textbox to label

There is no caption in the label to retrieve.
Reputation Points: 40
Solved Threads: 24
Junior Poster
SCBWV is offline Offline
125 posts
since Apr 2007
Feb 18th, 2009
0

Re: textbox to label

aha! No Caption Set Yet!
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 18th, 2009
0

Re: textbox to label

What do you mean no caption?

i want to input data first in the textbox and automatically connect the inputted data in the label.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dollmar is offline Offline
16 posts
since Feb 2009
Feb 18th, 2009
0

Re: textbox to label

Private Sub Form_Activate()
Form2.Label1.Caption = Form1.Text1.Text
End Sub
Reputation Points: 15
Solved Threads: 4
Junior Poster in Training
arvin2006 is offline Offline
69 posts
since Sep 2006
Feb 18th, 2009
0

Re: textbox to label

*Point Above*

You were assigning the value of the caption to the textbox, not the other way around. You can do this:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim x
  2. x = 5
you cannot do this:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim x
  2. 5 = x
These are not interchangeable....It only works the first way. So when you put:
vb Syntax (Toggle Plain Text)
  1. form1.text1.text = form2.label1.caption
you are saying (with no exception) "I want text1 to now contain the data stored in label1".
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 18th, 2009
1

Re: textbox to label

Give this code in Form1 :-

Private Sub Text1_Change()
Form2.Label1 = Text1.Text
End Sub
Reputation Points: 11
Solved Threads: 1
Newbie Poster
Ravi Kant is offline Offline
13 posts
since Jan 2009
Feb 18th, 2009
0

Re: textbox to label

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..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dollmar is offline Offline
16 posts
since Feb 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Read sheets on xls file
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB Project





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC