in a form
is load/unload the same as visibility =true /visibility=false
Printable View
in a form
is load/unload the same as visibility =true /visibility=false
That would be no. Load brings it into memory, Visible shows it to the user. As well as Show.
just discovered that the unload method actually unloads the form from the memory while the hide just hides the form.
what i dont understand is that if you have a project with multiple forms,
the project properties determines the startup object, however since all the other forms have their visibility set to true, then should not all the other forms be displayed behind the startup form?
or do i have to explicitly tell the forms to show themselves by doing a
fooformfoo.show()
The other forms are not loaded and therefor not shown. And yes you can load and show a form by calling the Show method. You can also load a form using the Load statement:However that will only load the form not show it regardless if the Visible property is set or not. You still need to call Form2.Show after that.VB Code:
Load Form2
So what's the difference? Well sometimes you might want to load a form and keep it in memory but not showing it before a special event is raised. This might be because you have a lot of controls on the form and it takes a long time to load.
You are going the right way.Quote:
Originally Posted by vb_student
You have done quite a lot of multiple posts on this topic.
I answered one in another thread, but will do it again.
A FORM gets loaded when you reference it. That means SHOW or LOAD - or even simply referencing a property or method of that form. So setting a form that is not loaded yet to visible will implicitly load that form.
This can be a good and bad thing.
When a FORM is loaded is the first time the form objects and code are loaded from the .EXE into memory.
This was required in the days of "small memory" processors - when loading and unloading forms was required by the programmer to manage the application use of memory.
thanks for all the replies, it has cleared my confusions. i will avoid posting similar questions in different posts.
my last questions on this topic
if you have unloaded a form, and you reference a public variable or function of that unloaded form then does that load that cause the form to be loaded into memory implicitly, since the variable/function can not be accessed unless it resides in the memory?
obviously i understand that a form can not be destroyed,so my question to how to destroy a form is meaningless, correct?
also at the begining is only one form loaded (the one pointed to by the project settings) into memory and the rest as the yare called?
If you UNLOAD the form and then again reference a form variable or property, that form does get loaded.
But the value will be re-initialized - don't think that the value that the form variable had initially will still be there - the UNLOAD cleared all that from memory.
Destroy? UNLOAD pretty much destroys the form in memory. What level of "destroy" are you wondering about?
We typically do not have a FORM loaded at startup, but instead a MAIN SUB in a MODULE. This SUB can determine certain things before any forms are loaded.
For example, we want to detect if the APP is already running - so it doesn't run again. That's done in non-form logic.
Also, there could be times you want an app to optionally run unattended - scheduled in the back ground. In that case, you want no screen interaction at all.
No exactly. Reference to a form's public variables or methods will not implicitly Load the form unless one of the form's controls or built-in properties (e.g., Caption) are referenced. What it will do is implicitly instantiate the form object. That is, the Initialize event will fire, but the Load event will not.Quote:
Originally Posted by vb_student
I disagree. The form can be destroyed - as signified by the firing of the Terminate event. This occurs when the form is no longer visible and all references to it are set to Nothing.Quote:
Originally Posted by vb_student
If the project's startup object is a form (it doesn't have to be), then only that form will be instantiated (brought into memory), loaded and shown - all others remain out of memory.Quote:
Originally Posted by vb_student
I've noticed that some people seem to be confused by the term "loaded". There are two conotations to this word.
1) Loaded into memory - instantiated (which makes available the form's public variables and methods);
2) and Loaded as in the command "Load Form1" (which makes available the form's visual components - e.g., controls and form properties).
#1 fires the Initialize event (the opposite of which is Terminate), #2 fires the Load event (the opposite of which is Unload).
As usual, the MSDN provides an excellent resource in this article: Life Cycle of Visual Basic Forms