Source code for Issue Number 14

Copyright 1997-2000 by C&D Programming Corp. All Rights Reserved. Source code may not be reproduced except for use in a compiled executable. All rights reserved. If you would like to reprint any or all of this code please email us at info@codeoftheweek.com

Code of the Week Home


Source Code

Just paste this code into any module (this is the desired way) or form. To do this, open up your project and insert a new Module. Change the name of the module to basGeneral and paste this code into the module.

'----------------------------------------------------------------------
'
'   Module Name:    basGeneral
'   Written By:     C&D Programming Corp.
'   Create Date:    11/22/97
'   Copyright:      Copyright 1997 by C&D Programming Corp.  Source
'                   code may not be reproduced except for use in a
'                   compiled executable.  All rights reserved.  If
'                   you would like to reprint any or all of this
'                   code please email us at info@codeoftheweek.com
'
'   Purpose:        Unload all forms
'
'----------------------------------------------------------------------
Public Sub UnloadAllForms()
        Dim x As Integer

        On Error Goto Handler

        ' we step backwards to ensure we
        ' unload all forms.
        For x = Forms.Count - 1 To 0 Step -1
                Unload Forms(i)
                Set Forms(x) = Nothing
        Next
End Sub

Handler:
    Err.Raise Err.Number, "basGeneral.UnloadAllForms", Err.Description
End Sub