My application makes use of different forms.I call forms by ‘hide’ the current form and ‘show 1’ to showthe next one.When I want to return to the previous form I use ‘hide’ or’unload’ the current form and ‘show 1’ the first one.so to go from my mainform to the next one using a commandbutton:
frmMain.HidefrmInput.Show 1and to go back from frmInput to frmMain (also using a commandbutton):
frmInput.Hide (or Unload frmInput)frmMain.Show 1The problem is that when I go from frmMain to frmInput and back for say 5 or 6times, I get the errormessage ‘Out of Stack Space’. First I thought it was a memoryvarible-problem, but when I use the Call method I saw 1 frmInput call and about 10 frmMain calls, so the stack was full.How can I make my program work so I don’t have this problem anymore?I think it’s a sort of problem that VB opens frmMain everytime I go back to frmMain, but I only want to open it once.
I would recommend that you always unload a form when you are done with it. Depending on the way your program is written now, that may be somewhat difficult. However, replacing all of your hides with unloads may get you more time. I’ve run into the same problem before.Probably the easiest way to change all of the calls would be to do a global search and replace. Don’t tell it to “replace all” though, find each one singly and decide whether or not you need to replace it.Also, I would consider carefully the need to make your forms modal. Only do this if the program actually needs a modal form in a given situation.