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

Pass a value from child Win form back to textbox of parent Win Form

P: 2
I have Form1 launches Form2. On Form2, user will enter input (a string).

When I click OK to close Form2, I need to have that string value populated TextBox1 on Form1 (the parent form).

I only find clues on doing the other way (passing from parent to child), which I have already been doing fine. But don't know how to let child form recognize (already opend/launched) parent form to access control there.

Thank you!
Dec 21 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 5K+
P: 8,434
What version of VB are you using?

And just out of curiosity, how are you passing info from parent to child?

(Have you considered the use of global variables?)
Dec 21 '07 #2

P: 2
Visual Studio 2005.

Here is what I used on parent form to launch the child form:

Dim UserDefinedForm As New diagUserDefined
UserDefinedForm.txSelected.Text = "Passed from Parent"

It works fine and on diagUserDefined win form, the string shows up. But when I need to get a string on this form, how should I pass it back onto a text field of the parent?

Thank you!
Dec 21 '07 #3

Expert 5K+
P: 8,434
Why can't you just access the controls on the parent or child form in the same way? I konw you can in VB6, but not sure of the syntax in later versions.

Note that one thing which may cause you problems is if you're trying to access controls on a form after closing the form. I don't think it's possible. At a guess, VB would load the form again (but not show it), and the controls would contain whatever defaults they start with.
Dec 21 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.