Search Tools Links Login

Close all MDI Child except me


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.

Original Author: Mihir Solanki

Code

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

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 105 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.