Unload vs. Hide

Question:
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 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 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.

Answer:
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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS