Solved

best way to write unloading forms vb6

Posted on 2014-02-08
5
266 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 45

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 45

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 45

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now