Tools Links Login

Forms Unloader

This code unloads all the forms of the program returning the resources back to the computer

Original Author: rbennett

Inputs

Optional force input as a boolean

Assumptions

This code is pretty straight forward and an understanding of loops and arrays is will help.

Code

Private Sub unloader(Optional ByVal ForceClose As Boolean = False)
  Dim i As Long
  
On Error Resume Next
  For i = Forms.Count - 1 To 0 Step -1
    Unload Forms(i)
    Set Forms(i) = Nothing
    If Not ForceClose Then
      If Forms.Count > i Then
        Exit Sub
      End If
    End If
  Next i
  
  If ForceClose Or (Forms.Count = 0) Then Close
  If ForceClose Or (Forms.Count > 0) Then End
  
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 75 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.