regarding loading of forms in the begining
Hello
when we start the project, are all the forms loaded unless stated otherwise
i checked for a load/unload property at designtime in the properties, but there is none.
my understanding is that all forms are loaded at runtime, and then in the first form they may be unloaded.
how do i destroy a form, remove it from the project completely at runtime?
Re: regarding loading of forms in the begining
If you want to remove a form, remove it from your project at design time. Make sure any reference to this form is deleted from your project code (although, you will get an "object not found" if you miss something.)
Re: regarding loading of forms in the begining
I was most definately not under the impression that all forms are loaded at startup. Naturally, I could be wrong, but I believe that you must load them yourself. You could test that theory out by trying to make a form do something at startup like:
frmTest.visible = True
If the form shows up, then it is already loaded. I think. Unless .visible acts like .show. I have thoroughly confused myself. Shutting up now.
Re: regarding loading of forms in the begining
Forms must be loaded at runtime.
That actually calls the forms objects and code into memory.
Simpy referring to a form object, variable, method or property will cause it to load, so simply setting the form .VISIBLE will also cause it to load.
Re: regarding loading of forms in the begining
just wanted to check
does this mean all the forms ae loaded in the begining, only that they are not visible?
Re: regarding loading of forms in the begining
Quote:
Originally Posted by vb_student
just wanted to check
does this mean all the forms ae loaded in the begining, only that they are not visible?
No - they are not loaded. The form objects and code sits on disk in the EXE until you start referring to it.
You got a nice post to a link about the life-cycle of the form (MSDN help). That goes over the difference between ACTIVATE and LOAD.
FORMS must get loaded at runtime - by your actions in the program. That is what I meant.
Re: regarding loading of forms in the begining
what post are you referring to?
Re: regarding loading of forms in the begining
Quote:
Originally Posted by szlamany
... Simpy referring to a form object, variable, method or property will cause it to load, ...
This isn't entirely correct: when you try to access form's public variable and/or form's custom property - form WILL NOT be loaded.
To test this add 2 forms to your project, declare 1 public variable as string on from2, add 2command buttons to form1 and run the following sample:
VB Code:
'FORM1
Private Sub Command1_Click()
Form2.strTest = "Hello"
End Sub
Private Sub Command2_Click()
MsgBox Form2.strTest
End Sub
'FORM2
Option Explicit
Public strTest As String
Private Sub Form_Load()
MsgBox "Form2 is loading"
End Sub
As you can see we are trying to set and read value to/from strTest on Form2 but message isn't showing which means form2 as object was not even initialized. It's due to compiler storing form's custom properties and (form's) public variables in a different name space.
However, form will get loaded when you make reference to any of its controls or Intrinsic properties.
Re: regarding loading of forms in the begining
Quote:
Originally Posted by vb_student
what post are you referring to?
I'm referring to the QUOTE'd post you made - but since we have more than one post, they overlap.
And RhinoBull is completely correct - in that form level standard properties invoke the form.
But you know that already from the life-cycle-of-a-form link that was given to you - right?
Re: regarding loading of forms in the begining