Click here to Skip to main content
15,881,639 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi There,

I want to be able to pass text string from a textbox on One form to textbox on another form. So basically textbox1 (formA) to textbox1 (FormB). Is there a simple method for this to be achieved.

Any help would be great....i do have abit of code bit it doesnt always work.

Cheeeers
Posted

 
Share this answer
 
Comments
Espen Harlinn 30-Aug-11 16:32pm    
That would help, my 5
Sergey Alexandrovich Kryukov 30-Aug-11 17:20pm    
There is a little problem in this way -- please my comment and solution. I think you already knew what I propose in such cases.
--SA
SIFNOk 30-Aug-11 16:45pm    
This is the code i have been using... and as stated before for some reason it does not work in my project no matter how much i maniplute it...any ideas what would cause thiss?
Sergey Alexandrovich Kryukov 30-Aug-11 17:20pm    
It will work, but some problem is that the one form instance should get a reference to another form instance -- not appropriate isolation between the two. That's why it's much better to pass just an interface reference -- please see my solution. I voted 4 for this one.
--SA
Sergey Alexandrovich Kryukov 30-Aug-11 17:23pm    
Do not manipulate -- implement it yourself with full understanding of what you are doing, using the idea. If you stuck, make a ***simple*** code sample and post it. In fact, start with a simple code sample and later apply it to your real-life project. I suggest you use my way.
--SA
The Simplest Is Here

If You want to get textString from FormA to FormB
then First make the Modifiers property of textBoxes to Friend .
And Try this.
Under Form Load event of FormB
VB
textBox1.text = FormA.textBox1.text

you Can Get the Value by Declaring any String also.
But You must Hide or Send to Back your FormA.
It will not work If you Close the FormA.
So under your Close Button Code there to hide the form.

may this Can help you
 
Share this answer
 
As the question turned out to be very popular, and my previous answers often were not well understood, probably were not clear enough, I decided to write a Tips/Trick article complete with detailed code samples and explanations: Many Questions Answered at Once — Collaboration between Windows Forms or WPF Windows.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900