|
-
Jan 7th, 2005, 06:46 AM
#1
Thread Starter
Frenzied Member
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?
Last edited by vb_student; Jan 9th, 2005 at 12:13 PM.
-
Jan 7th, 2005, 06:56 AM
#2
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.)
-
Jan 7th, 2005, 06:58 AM
#3
Addicted Member
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.
Sherminator ~ I'll be back.
-
Jan 7th, 2005, 07:04 AM
#4
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.
-
Jan 8th, 2005, 07:55 AM
#5
Thread Starter
Frenzied Member
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?
-
Jan 8th, 2005, 08:24 AM
#6
Re: regarding loading of forms in the begining
 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.
-
Jan 8th, 2005, 06:47 PM
#7
Thread Starter
Frenzied Member
Re: regarding loading of forms in the begining
what post are you referring to?
-
Jan 8th, 2005, 07:02 PM
#8
Re: regarding loading of forms in the begining
 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.
-
Jan 8th, 2005, 07:14 PM
#9
Re: regarding loading of forms in the begining
 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?
-
Jan 10th, 2005, 06:40 AM
#10
Addicted Member
Re: regarding loading of forms in the begining
Sherminator ~ I'll be back.
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
|