By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,639 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,639 IT Pros & Developers. It's quick & easy.

Winforms Question.

P: n/a
Hi there,

I'm trying to trasfer some data from one form to another. I know I could use
global variables to trasfer the data from one form to another. I know is got
to be another way to do this not involving global variables.

Can anybody give some advices or hints or some ways that I can do this?

Thanks very much.

Manuel

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Thanks Scott,

I thought about inheritance for sure, but as you said is not the prettiest.
My forms are totally different from each other. If I inherit from the first
form, all the controls from the first form will show up on my second form,
not good.

I need need the information from 5 or 6 text boxes to be transffered into my
second form. that's all I need.

Thanks,

Manuel
"Manuel Canas" <mc*****@hotmail.com> wrote in message
news:9HKXc.20095$A8.16705@edtnps89...
Hi there,

I'm trying to trasfer some data from one form to another. I know I could use global variables to trasfer the data from one form to another. I know is got to be another way to do this not involving global variables.

Can anybody give some advices or hints or some ways that I can do this?

Thanks very much.

Manuel

Nov 21 '05 #2

P: n/a
Manuel,

You can share data between forms a few different ways (probably more than
what I'll suggest). First you can use shared variables.

Form1:
Public Shared var1 as String
var1 = txtbox.Text

Form2:
Dim myvar as String
myvar = Form1.var1

Another way you can share data is to pass it to the form through a
constructor.
Form1
Dim form2instance as New Form2(txt1.Text, txt2.Text)
form2Instance.Show()

Form2:

Dim myval1 as String
Dim myval2 as String

Public Sub New(Byval var1, Byval var2)
Mybase.New()
InitializeComponent()
myval1 = var1
myval2 = var2
End Sub

Hope this helps

-Matt

"Manuel Canas" <mc*****@hotmail.com> wrote in message
news:9HKXc.20095$A8.16705@edtnps89...
Hi there,

I'm trying to trasfer some data from one form to another. I know I could
use
global variables to trasfer the data from one form to another. I know is
got
to be another way to do this not involving global variables.

Can anybody give some advices or hints or some ways that I can do this?

Thanks very much.

Manuel

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.