Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

Passing Value back from a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
robin9876@hotmail.com - 25 Jan 2007 13:52 GMT
In a windows form application created in VS 2005 VB.Net I have one form
which calls another form and supplies a value. In this additional form
I need to return a value back. Below is the code to call the other
form.

Dim x As New myForm2
x.aValue = Me.TextBox1.Text
x.Show()

How can I return a value back from myForm2 back to myForm1 where the
above code is located on a button click event?
RobinS - 25 Jan 2007 22:00 GMT
I would set up a property on myForm1 and have myForm2 access
the property to set it.

As for the first part, you might want to consider adding a
constructor to your myForm2 that accepts a string, and pass
that value in instead of using it as a property. This makes
it more obvious if anybody else ever uses your form, that the
value needs to be (or can be) set when creating the form.

Robin S.
-----------------------------
> In a windows form application created in VS 2005 VB.Net I have one
> form
[quoted text clipped - 8 lines]
> How can I return a value back from myForm2 back to myForm1 where the
> above code is located on a button click event?
ClayB - 26 Jan 2007 10:14 GMT
Another solution is to declare aValue as a public member of Form2. Then
within Form1, you can directly reference x.aValue (provided you keep a
reference to x in scope).

================
Clay Burch
Syncfusion, Inc.
robin9876@hotmail.com - 26 Jan 2007 11:11 GMT
I ended up doing that by using the showdialog option from the call in
form1 to keep the form in scope until after form2 was closed.

> Another solution is to declare aValue as a public member of Form2. Then
> within Form1, you can directly reference x.aValue (provided you keep a
[quoted text clipped - 3 lines]
> Clay Burch
> Syncfusion, Inc.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.