|
-
Aug 29th, 2006, 04:26 AM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] loading and closing problems..
Hello,
I have an application using with a lot of forms ,
in every form there is a close button like - me.close()
So when I run the program it shows the main form ,I push button and it shows the second form , but when I push close button in second form and it closes it , when tring to push button to execute form 2 again , it doesn't work, why?
should I do form2 unload or something ?! I want to be able to operate form 2,3,4,5...etc , again after I closes them..
Anyone have an idea?

Giving an exact answer
Saves a lot of time!!!
-
Aug 29th, 2006, 04:31 AM
#2
Re: [2005] loading and closing problems..
don't close the second button it desposes the form object. Insted hide it or set the visible property to false.
-
Aug 29th, 2006, 04:33 AM
#3
Re: [2005] loading and closing problems..
Forms are objects. When you Close a form that was displayed using Show you destroy it, so it cannot be displayed again. If you want to display another form of the same type then you need to create another form of the same type. If you want the same form object then don't destroy it. Call Hide instead of Close. Having said that, do NOT hide the form unless you specifically need the same instance then next time you show it.
-
Aug 29th, 2006, 04:38 AM
#4
Thread Starter
Addicted Member
Re: [2005] loading and closing problems..
thank you both for the explanation , but if I hide or set visible.false
it uses a lot of memory ,and I want the form not to take memory from the system while I'm not using it , what option should I choose?

Giving an exact answer
Saves a lot of time!!!
-
Aug 29th, 2006, 04:44 AM
#5
Re: [2005] loading and closing problems..
If you don't want to use memory then you need do declare the forms as New in the button click event.
VB Code:
Dim frm2 As New Form2
frm2.Show()
and than you can use
method from form2 to close the form.
-
Aug 29th, 2006, 04:47 AM
#6
Thread Starter
Addicted Member
Re: [2005] loading and closing problems..
Sorry about misunderstanding..
I should write this code for whole my forms, and then to put - form2.hide
when I want to unload the form??

Giving an exact answer
Saves a lot of time!!!
-
Aug 29th, 2006, 04:53 AM
#7
Re: [2005] loading and closing problems..
1. yes you need to use
VB Code:
Dim frm2 As New Form2
frm2.Show()
for all but form1 in the form1's OpenForm button click event.
For the form1 you don't have to do anything but for the rest you need to declar them as New.
2. And no, if you declare the forms as new then you need to use
from these forms close button click event. Don't hide them.
-
Aug 29th, 2006, 05:18 AM
#8
Thread Starter
Addicted Member
Re: [2005] loading and closing problems..
Got it! thank you very much!

Giving an exact answer
Saves a lot of time!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|