Multi Form App in VB.NET

woklet

Freshman
Joined
Mar 9, 2005
Messages
29
From my main form, in a combo box, I call a second form like this:

dim NewForm as form2
NewForm = new form2
NewForm.show

After the user completes their work in form2, I need to get back to form1. How can I do this? If I do this from form2...

dim OrigForm as form1
OrigForm = form1
form1.show

...it creates another instance of form1. I need to get back to my original form1. How can I go back and forth from one form to another without re-creating them each time?

Thanks in advance
Ben
 
Answer I think

If form1 is your startup form it should still be open. All you should have to do is close form2 and the program should refocus on form1 you do not need to add any additional code.
 
I could be wrong, but from the little you've said I would guess that you want a modal dialogue, i.e. a dialogue that prevents access to its opener until you dismiss it, like a MessageBox. If I am correct, you should display your form by calling ShowDialog instead of Show. ShowDialog does not return until the new window is closed, at which point it returns the value of the form's DialogResult property, which is supposed to indicate what button was used to dismiss the form, once again like a MessageBox.
 
Back
Top