how do i close all forms except main form 2022-TechbyMati

VB.Net-Forms  Clossing Method


    close all Forms except main form VB.Net

    Private Sub close_all()
            Dim formNames As New List(Of String)
            For Each currentForm As Form In Application.OpenForms
                If currentForm.Name <> "frmmain" Then
                    formNames.Add(currentForm.Name)
                End If
            Next
            For Each currentFormName As String In formNames
                Application.OpenForms(currentFormName).Close()
            Next
        End Sub

     

    Your Code Here

    Matibar

    Blogger

    Thank You

    Previous Post Next Post

    Contact Form