?
Solved

best way to write unloading forms vb6

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

719 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