Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I searched for an answer to this question and found an exact duplicate but the link the replier posted was dead so here I am.

 

Anyway, here's my problem, I have my main form and upon a button click, another form pops up. Now what I want is when I input info into the textbox found on the second form, upon closing the second form, I want the info to show up in an input box in the main form.

 

I have seen where people are using classes but I'm used to VB6 where you can just reference the textfield on the main form and update the info that way. I'm looking to see if there's a different way. If someone could help me I'd greatly appreciate it.

Posted

You could try to pass the first form into the second form, like

 

Dim frmSecond as new frmTheSecond(Me)

 

In the frmTheSecond, you would add the code in the initialize section that reads:

 

Public Sub New(frmFirst as frmTheFirst)

MyClass.New()

originalForm = frmFirst

End Sub

 

Also, add a private variable to the Class called originalForm As Form

 

If you want to populate the original form with data, simply say

 

originalForm.txtUpdate.Text = txtWhatever.Text

 

That should do, maybe I am not completely correct, I made this up from memory ...

 

Off course, there are other ways to do this as well.

 

And in general, even if you are a VB6 Programmer, you should get started to get used to do things the .NET way, it is here for good (no offense).

IS
  • Leaders
Posted

VB6 is very different from VB.NET, but I'm sure you knew that already... (VB6 forms were ahead of their time)

 

Have you seen this thread?

http://www.xtremedotnettalk.com/showthread.php?s=&threadid=82585

You can create a Shared string property in your second form class, write the textfield into the property from the second form, and then read it from the first.

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

  • Leaders
Posted
Then, why not declare it as Public instead of Friend?

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...