VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Forms Unloader

by rbennett (3 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

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

Inputs
Optional force input as a boolean
Assumes
This code is pretty straight forward and an understanding of loops and arrays is will help.

Rate Forms Unloader

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

Download this snippet    Add to My Saved Code

Forms Unloader Comments

No comments have been posted about Forms Unloader. Why not be the first to post a comment about Forms Unloader.

Post your comment

Subject:
Message:
0/1000 characters