Solved

best way to write unloading forms vb6

Posted on 2014-02-08
5
270 Views
Last Modified: 2014-02-08
i am trying to determine the best way to write this procedure that is in the main form
and is ran after a bonus

 'bonus runs complete unload loaded forms
     
          If IsFormLoaded("frmBonus12") Then 'function bonus start form first screen to always show
                'informing user that 12 free runs are won all wins are doubled
                  Unload frmBonus12 'function
                  Set frmBonus12 = Nothing 'release any public variables
                End If
                  
                If IsFormLoaded("frmCleoBonus") Then 'function bonus 80 number grid to run 12 times
                  Unload frmCleoBonus
                  Set frmCleoBonus = Nothing 'release any public variables
                End If
                
                If IsFormLoaded("frmBonusComplete") Then 'function bonus result if no bonus win
                  Unload frmBonusComplete
                  Set frmBonusComplete = Nothing 'release any public variables
                End If
                  
                If IsFormLoaded("frmBonusWin") Then 'function bonus result if a win with images of numbers
                   Unload frmBonusWin
                   Set frmBonusWin = Nothing 'release any public variables
                End If

Open in new window

maybe i don't need to check if a form is loaded before unloading it or setting it to nothing
also i think instead of all the if's I could use ElIf
Information requested
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 47

Expert Comment

by:Martin Liss
ID: 39844473
Dim frm As Form

For Each frm In Forms
    ' There could also be an If frm.Name = "blah" or frm.Name ="Yada" Then...
    Unload frm
    Set frm = Nothing
Next

Open in new window

0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39844633
BTW, the Forms collection that my For/Next loop looks at only includes forms that are loaded, so you don't need to account for or worry about the ones that aren't loaded.
0
 

Author Closing Comment

by:isnoend2001
ID: 39844723
Is this correct ?
Dim frm As Form

For Each frm In Forms
    ' There could also be an If frm.Name = "blah" or frm.Name ="Yada" Then..
The calling frm = frmCleo which will not be unloaded
 if not frm = frmCleo then
    Unload frm
    Set frm = Nothing
end if
Next
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 39844752
Instead of

if not frm = frmCleo then

do

if frm.Name <> " frmCleo" then
0
 

Author Comment

by:isnoend2001
ID: 39844873
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question