Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

best way to write unloading forms vb6

Posted on 2014-02-08
5
Medium Priority
?
273 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 49

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 49

Accepted Solution

by:
Martin Liss earned 2000 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 49

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

824 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