QUOTE
4) In the code window type:
CODE
Dim Form as new Form2
Form.Show
5) That show the form. This step is not required. Use only if you want to hide the first form.
CODE
Me.Hide
you can also unload your form instead of just hiding it!
CODE
Private Sub Command1_Click
me.unload
End Sub
should be enough to properly close the form. there is more on unloading forms and how to do it in this topic >>
http://www.astahost.com/index.php?showtopi...b.net+unloadingwhen you hide a form you are leaving it in the momory just hidden from the user. now this is ok for smaller applications and you ca get away with it. but if you are making applications that need memory and lots of it, or you are building for computers that may not have much memory, you are going to need the memory that the hidden form is taking! unloading the form takes back this memory and can use it elsewhere.
also, the only time visual basic will close the program properly is when
all the forms are closed, if you still have open forms (they are hidden but still open!) visual basic will not close the program and it will continue to run! This is not a good thing to get into! it is alright when you are in a debug environment and you can just press the 'stop' button to end debugging! but what happens when there is an end use that loads the program, uses it then closes it, the program is still running in the background, again using memory!
hiding forms though can still have its advantages! if you were planning to use information on that form later in your program and didn't want to put them into public variables, then you can leave the form running just to keep the information, then once its been used to moved to a better place, you can close the form.
if you do hide forms all the time and want to close a program properly you can use one line of code to close all your hidden forms and end the program.
CODE
Private Sub Command1_Click
end
End Sub
is all you need to close the program and get rid of all the hidden forms
good luck programming
-jimmy
Reply