like in vb 6, how can I unload a form and show another in VB.Net?
Printable View
like in vb 6, how can I unload a form and show another in VB.Net?
if you wanna unload the current form:
me.close
to load another one:
dim frm as new form2
frm.show
hi thanx for your patience Mr.Polite
I tried that but getting an error while compiling
(ie; me.close())
variable 'Close' conflicts with sub 'Close' in the base class 'Form' and so should be declared 'Shadows'.
please help
Me.Close() works. You probably have a variable named "close" in your form and as it says, it has a conflict with that. Just rename your variable. I guess that's the problem:rolleyes:
I dont know about the Shadows keyword, never worked with it. I guess you could solve it without renaming it too
thanx mr.Polite
you were right.
now the problem is the next form is not showing. Instead the application exits. i have written in a button's
me.close()
dim frm as form2
frm.show
but it didn't work
i tried this also
dim frm as form2
frm.show
me.close()
can u help me?
The first form opened maintains the thread of the application. If you close it then it closes the application also. You can use ShowDialog to show another form modally which will keep the main form from unloading until the new form is done.
hi ednees
means we can't do as it in vb6. right?
Right its a little bit different. We can't unload and load any forms anymore. Well we can just not the main form, any others will work like they did in vb6.
Try this and tell me if it helps : Add a new module to your application and create new instances of the forms in a sub main and then show the forms modally.
in your form1 you should write some code to find out how the form is closed. for example if the user clicks a button to go to form2 you can have that button to act as dialog cancel button but there should be a difference between that and the exit button of the form.Code:sub main()
dim f1 as new form1
dim f2 as new form2
'some codes to customize form1
f1.showdialog
'some codes to customze form2
f2.showdialog
end sub
ya it's working. thanks Lunatic3.