VB.NET How to check if a Form is already Open

VB.NET How to check if a Form is already Open

image of How to check if a Form is already Open
Check if Form is open in Visual Basic .NET

Visual Basic 2010 Windows Form [WinForm] Project

.NET 4

Microsoft Windows 10 32 or 64bit

Form1

Text : MainFrm.vb

Button1

Text : OK!

Form2 

Text : SecondFrm.vb

Now, in order to check if Form2 is open or not, and if open then Show it, or if it is not open then Open it, the code would be.

  • Public Class MainFrm
  1. Private Sub PictureBox4_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox4.Click
  2. OpnFrm = New SecondFrm
  3. If Application.OpenForms.OfType(Of SecondFrm).Any Then
  4. OpnFrm.Select()
  5. Exit Sub
  6. End If
  7. OpnFrm.Show(Me)
  8. End Sub
  • End Class

 Here are some online Visual Basic lessons and courses :

Popular posts from this blog

VB .NET Google Drive Api Source Code Example

VB .NET DropBox Api Source Code Example

VB .NET WebView2 WinForms tips

Visual Basic Online Courses DataGridView Add Edit Delete

Visual Basic Online Course DevExpress 12.2.4 full for Visual Studio 2010

Visual Basic 2010 Working With DataBase Full Project Example