Click to See Complete Forum and Search --> : showing form
afterMoon
Oct 31st, 2002, 12:36 AM
like in vb 6, how can I unload a form and show another in VB.Net?
MrPolite
Oct 31st, 2002, 12:40 AM
if you wanna unload the current form:
me.close
to load another one:
dim frm as new form2
frm.show
afterMoon
Oct 31st, 2002, 12:52 AM
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
MrPolite
Oct 31st, 2002, 01:04 AM
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
afterMoon
Oct 31st, 2002, 02:41 AM
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?
Edneeis
Oct 31st, 2002, 04:19 AM
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.
afterMoon
Oct 31st, 2002, 07:31 AM
hi ednees
means we can't do as it in vb6. right?
Edneeis
Oct 31st, 2002, 10:28 AM
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.
Lunatic3
Oct 31st, 2002, 03:51 PM
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.
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
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.
afterMoon
Nov 1st, 2002, 12:34 AM
ya it's working. thanks Lunatic3.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.