TechArena Community

TechArena Community (
-   Software Development (
-   -   Closing out a form in Visual Basic (

Adel123 31-08-2009 04:26 PM

Closing out a form in Visual Basic
Hi friends,

I have created an application in Visual Basic 6, where i have a splash form which calls main form, which calls many other forms too. But when i am trying to close the main form using unload me then steps through all of the unfinished procedures. Is there any way I can prevent this from happening and should i mention few global variables at the same time.

Reegan 31-08-2009 04:35 PM

Completely closing out a form
If that's the case then i would suggest you hide all your frames by using the following code

FrmMain1.Visible = False
or even
frmMain1.Left= -10000 ' sticks the form way off screen

At the same time if you think that any form is very heavy then try to many the functions and variables as possible to a bas module. Also make a note that as as long as even a single variable on a form is active/needed then the form will stay in memory. If the function of the Main form is to call others then i would suggest you to use a Sub Main rather than a form to serve as a switchboard.

Adel123 31-08-2009 04:41 PM

Closing out a form in Visual Basic
Thanks for replying me but i don't want any of my form to be hiding, i need to completely clean NEW instance of the form, according to me a variable is still being active which is the root cause of my problem. How can I ensure that none of the variables are still needed.

Bassus 31-08-2009 04:56 PM

Closing out a form in Visual Basic
In that case simply move everything in declaration section of the form to bas module and also move procedures which are not directly linked to the form to the bas module and also remove any calls to the controls from modules or other forms or else you can also use the following code too


unload Mainform1
unload Mainform2

Dim frmOpen As form1
Set frmOpen = New form1

All times are GMT +5.5. The time now is 01:02 PM.