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?

Re: Passing Value back from a form by RobinS

RobinS
Thu Jan 25 16:00:14 CST 2007

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.
-----------------------------
<robin9876@hotmail.com> wrote in message
news:1169733144.313359.317330@k78g2000cwa.googlegroups.com...
> 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?
>



Re: Passing Value back from a form by ClayB

ClayB
Fri Jan 26 04:14:07 CST 2007

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.


Re: Passing Value back from a form by robin9876

robin9876
Fri Jan 26 05:11:12 CST 2007

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.

On Jan 26, 10:14 am, "ClayB" <c...@syncfusion.com> wrote:
> 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.