Results 1 to 15 of 15

Thread: Probem with Unloading forms...<resolved!>

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104

    Probem with Unloading forms...<resolved!>

    hey, im having a problem with the unloading of forms. For my project, its a fishing game and when you acheive a certain amount of points you move onto the next level (and next form). So in the point sub, when you reach this amount, it unloads the current form and loads the next one. THe problem is, when I unload the form and load the next form, it starts up the Form_Load event of the form it just unloaded! How can I unload it properly so it doesnt trigger the Form_Load event

    Incase you dont get understand what i mean:

    Form1 loads up from the start. When you reach 1000 points Form1 unloads and disapears and Form2 loads up. However, while Form2 is loading up, it triggers Form1's Form_Load event for some reason. I checked in everything to make sure I dont have a Form1.load event that I overlooked.

    Is this suposed to happen maybe? Im a novice, so bear with me. Thanks.

    ~INNO~
    Last edited by Inno; Jun 15th, 2002 at 03:44 PM.

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    didn't decide yet
    Posts
    566
    a reason that it does that is maybe that u r checking properties of form1 from within form2. Say u have a control called cr in form1 if u check a property of cr from within form2 form1 will load again
    e.g if u check debug.print cr.name from form2
    Come and get our ISDN CallerID http://www.3wm.biz

  3. #3
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    make sure you have STOPPED any loops you may have.

    you can do something like this,
    private stoploop as boolean 'defaults to false

    inside your loop:
    If StopLoop = True then exit sub

    inside your form_queryunload (or form_unload)
    StopLoop = True
    form2.show
    unload me

  4. #4
    Hyperactive Member
    Join Date
    May 2002
    Location
    Chicago
    Posts
    271
    Are you sure it's the load event and not the activation or other event? Anyway
    try showing the next form before unloading the current:
    Code:
      Form2.Show
      Unload Form1
    Sometimes what you're looking for is exactly where you left it.

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Originally posted by tina104291325
    a reason that it does that is maybe that u r checking properties of form1 from within form2. Say u have a control called cr in form1 if u check a property of cr from within form2 form1 will load again
    e.g if u check debug.print cr.name from form2
    thats the biggest possibility. calling ANYTHING (properties, controls, variables, sub, functions) will load the form if it isnt already loaded. you will probably need to store information in modules, or you could unload form1 in form2 when it loads, after you have got the info you need from form1 and no longer need anything from form1
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104
    Hm, thanks for the fast replies,

    I have checked on everything you guys suggested.

    Tina - No, nothing in that form is being checked from within another form
    prog - I dont have loops, I dont even know how to work them yet :P
    John - Yes, the load event is activating even after the unload. And yes, I have it show the form before I unload the previous one.

    So, maybe I am overlooking something. If one of you guys wouldnt mind downloading the attached, that would be great. I just included the 2 forms that are conflicting. Run the project, Click the grey command button at the left of the screen (that will give u the points needed to pass the level instead of making u try and beat it =) ) then you will notice the msgbox that first appears at the begining gets repeated on the next form =/ Thanks for the help. Oh and also, can you tell me why the total score on the endscreen isnt adding up right. Thanks.

  7. #7
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by BuggyProgrammer


    thats the biggest possibility. calling ANYTHING (properties, controls, variables, sub, functions) will load the form if it isnt already loaded. you will probably need to store information in modules, or you could unload form1 in form2 when it loads, after you have got the info you need from form1 and no longer need anything from form1
    Form's public properties won't load a form.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  8. #8
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    hey it was a logical guess
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    I don't find the Form1
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  10. #10

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104
    Form1 is really Form8
    FOrm2 is really Endscreen

    I just used those 2 for examples...
    or did u mean something isnt working because there isnt a form1?
    I can post my whole project if needed...

  11. #11
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    It said "Load Form1" and "Form1.Show" and I couldn't test it.... Anyway, I'm not seeing what you were talking about.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  12. #12
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Just a tip... please, Indent your code!!
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104
    Hm, I think when i took the 2 forms from my other project and started a new standard EXE to add the forms to i deleted form1 from it, so thats why the error probly...can I email you my whole project? Or, anyone else?

  14. #14
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Sure... go ahead
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  15. #15
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Ok... if anyone is wondering the problem was the the Form8 got unloaded but inside a Timer event... so, the form gets loaded again. It's already fixed now.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

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