In this VB.Net Tutorial/Code Example I’ll be showing you how to check to see whether there is an instance of a form open in your application.

''' <summary>
''' This method deals with checking to see whether a particular form is open
''' </summary>
''' <param name="formName">The name of the form that you are looking for</param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function isFormOpen(ByVal formName As String) As Boolean
    Dim frm As Form
    Dim i As Integer = 0
    Dim found As Boolean = False

    While i < Application.OpenForms.Count
        frm = Application.OpenForms.Item(i)

        If frm.Name.ToLower = formName.ToLower Then
            found = True
            Exit While
        End If

        i += 1
    End While

    Return found
End Function{/code}
Check whether an instance of a form is open
Tagged on:     

One thought on “Check whether an instance of a form is open

  • 9 April 2014 at 5:55 pm
    Permalink

    Hi, I found your article, used it, it helped. Thanks!

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.