VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Close all MDI Child except me

by Mihir Solanki (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

This code will close all other MDI Child except the current activated one.Simply put this procedure in Module or Form itself..There are two different way to use it.

Rate Close all MDI Child except me

Option Explicit
'+++++++++++++++++++++++++++++++++++++
' First Style
' Use private procedure in Form
'+++++++++++++++++++++++++++++++++++++
Private Sub Form_Activate()
  UnloadOthers
End Sub
Private Sub UnloadOthers()
  Dim frm As Form
  For Each frm In Forms
    If frm.Name <> Me.Name And Not (TypeOf frm Is MDIForm) Then
      Unload frm
    End If
  Next
End Sub
'+++++++++++++++++++++++++++++++++++++
' Second Style
' Use Public Procedure in Module
'+++++++++++++++++++++++++++++++++++++
'Form Code
Private Sub Form_Activate()
  UnloadOthers me.Name
End Sub
'Module Code
Public Sub UnloadOthers(frmName as string)
  Dim frm As Form
  For Each frm In Forms
    If frm.Name <> frmName And Not (TypeOf frm Is MDIForm) Then
      Unload frm
    End If
  Next
End Sub

Download this snippet    Add to My Saved Code

Close all MDI Child except me Comments

No comments have been posted about Close all MDI Child except me. Why not be the first to post a comment about Close all MDI Child except me.

Post your comment

Subject:
Message:
0/1000 characters