jccorner Posted February 9, 2004 Posted February 9, 2004 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. Quote Applying computer technology is simply finding the right wrench to pound in the correct screw
I Schobert Posted February 9, 2004 Posted February 9, 2004 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). Quote IS
Leaders Iceplug Posted February 9, 2004 Leaders Posted February 9, 2004 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. Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
jccorner Posted February 9, 2004 Author Posted February 9, 2004 Public Sub New(frmFirst as frmTheFirst) MyClass.New() originalForm = frmFirst End Sub That's a no. The compiler would not let me declare frmFirst as frmTheFirst because it is declared as a Friend. Quote Applying computer technology is simply finding the right wrench to pound in the correct screw
Leaders Iceplug Posted February 10, 2004 Leaders Posted February 10, 2004 Then, why not declare it as Public instead of Friend? Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.