unload/show CodeThis continues over and over. After about 4 games, I get "Out of Memory" and the system crashes trying to load one of the bmp's.
Thank you for your time. The Hangman game is a project for school, at Southwest Texas State University in San Marcos, Texas.
From: Robert J. Rimes II
Email: rr07424@swt.edu
Why is this happening? Typically it's because you have some code like this, where you are going from your game form to your win/lose form and back.
Unload Me frmWinLose.Show MODAL
The problem with that is this: when you go back to the form in question you load it because you know that you unloaded it (as above) and you show it. Unfortunately you never actually unloaded it, because the code above never finishes executing. Why? Because the unload command is actually cued until all the code in that form has been processed, which means it won't actually unload until after that Show modal statement. Unfortunately because that show is Modal that statement will not return until the following form is unloaded. By that time the following form has loaded the first form again, and we are well on the way to running out of memory.
Basically what you need is a smoother way to transition between forms, your first step is to not use MODAL forms (which I have assumed you are using). That should allow unload calls like the above to finish executing. You might be interested to have a look at the article: Handling Chained Modal Dialogs in VB. The article includes some useful (and simple) code for transitioning between forms.
I hope this helps you out, your situation may be different to what I've described but I think the central problem is still that you end up with too many forms in memory. So have a close look at your unload/show code.