Form Load does not trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesnkk
    New Member
    • Nov 2006
    • 134

    Form Load does not trigger

    Hi, I am new to vb6.
    I have some code written in the form load. the first time when I call the form, the code inside form load will activate.
    After I have complete the form and return to main menu, the 2nd time when I call the form, it does not trigger the code in the form load, I put a debugging point on the code in the form load, but it not trigger, any idea what wrong ?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    kindly post your code here for reference of our experts.

    Comment

    • AIProgrammer
      New Member
      • Jul 2008
      • 28

      #3
      Hi,
      Seeing your code would have helped. I think you problem is that:
      PROBLEM:
      form_load() event is triggered only when the form is brought into memory(RAM) from the hard disk, where it exists as a file. So, when you 'switch back' to the form (e.g. by ALT-TAB), then this event is not raised.
      SOLUTION1 :
      put the code from form_load() to the Form_Activate() event of the form. This event is triggered when you 'activate' the form by ALT-TAB or mouse click etc.
      SOLUTION2 :
      This is bit less practical, and I would suggest to stick to previous solution.
      Unload the form(CODE : Unload Form) when you switch to the other form, and load (CODE: Load Form) when you switch back to the previous one. In this way, the form_Load() event will be triggered again.

      Think that should solve your problem, if I understood it right.

      Bye.

      Comment

      • GriffinWolf
        New Member
        • Jul 2008
        • 2

        #4
        I don't know how you have left the form, but if it is using the "Form.hide" command, this means that the form is still loaded, and when you come back to it, the program believes it has already done what you wanted. If this is the case, use "Unload Form1" instead of "Form.Hide" .

        Comment

        Working...