Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Unload vs. Hide

My application makes use of different forms. I call forms by 'hide' the current form and 'show 1' to show the 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:
frmInput.Show 1 
and to go back from frmInput to frmMain (also using a commandbutton):
frmInput.Hide (or Unload frmInput)
frmMain.Show 1
The problem is that when I go from frmMain to frmInput and back for say 5 or 6 times, 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.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date