Solved

best way to write unloading forms vb6

Posted on 2014-02-08
5
268 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
  • 3
  • 2
5 Comments
 
LVL 46

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 46

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 46

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 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