How do I close current form and open the next form ?

  • Thread starter Thread starter prob
  • Start date Start date
P

prob

I would like to acheive the following VB6 code in VB.NET

Code in the Form1 - Button1_Click

Dim obj1 as new form2
obj1.Prop = myprop
obj1.show
unload me
 
Look for the thread :
"VB.NET and FORMS (Form.Show, Form.Hide ... ) "

from (e-mail address removed)

in this group

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
If you close the current instance ... it closes all the
instances of its child

For ex

Dim x as new form2
x.show
me.close


will never shows form2.. it opens and closes immediately
 
Dim x as new form2
x.show
me.close


will never shows form2.. it opens and closes immediately

That's because you are probably using Form1 (Me) as your startup form.
When you close that, it closes the whole application.

Create a module and add a sub main to it. In the project properties, set
the startup object as Sub Main.


'Untested
Public Sub Main()
Dim frmMain As New Form1

frmMain.Show

Application.Run()
End Sub

With this method, you must call Application.Exit to close the application.
 
Back
Top