Results 1 to 10 of 10

Thread: regarding loading of forms in the begining

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2005
    Posts
    1,069

    Resolved 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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.)

  3. #3
    Addicted Member
    Join Date
    Nov 2004
    Posts
    171

    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.

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2005
    Posts
    1,069

    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?

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2005
    Posts
    1,069

    Re: regarding loading of forms in the begining

    what post are you referring to?

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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:
    1. 'FORM1
    2. Private Sub Command1_Click()
    3.     Form2.strTest = "Hello"
    4. End Sub
    5.  
    6. Private Sub Command2_Click()
    7.     MsgBox Form2.strTest
    8. End Sub
    9.  
    10. 'FORM2
    11. Option Explicit
    12.  
    13. Public strTest As String
    14.  
    15. Private Sub Form_Load()
    16.     MsgBox "Form2 is loading"
    17. 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.

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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?

  10. #10
    Addicted Member
    Join Date
    Nov 2004
    Posts
    171

    Re: regarding loading of forms in the begining

    Just to make sure, here it is.

    Life Cycle of Visual Basic Forms
    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
  •  



Click Here to Expand Forum to Full Width