Hi Guys!

I just need a little help on how to detect if a form is open or loaded.? When it is loaded or open, i want it to show or visible when a button is click..

Something like this...

if frmisOpen(frmname)=true then
   'show or load the form
end if

Thank you & God bless us.!

Edited 5 Years Ago by blocker: n/a

Use the instance method of the object(form) to check one instance is already running..

Edited 5 Years Ago by Pgmer: n/a

Sorry there is no such method called instance.
We need to write custome code to check.

Private Shared _Instance As Form1 = Nothing

    Public Shared Function Instance() As Boolean
        If _Instance Is Nothing OrElse _Instance.IsDisposed = True Then
            _Instance = New Form1
            Return False
        End If
        _Instance.BringToFront()
        Return True
    End Function

Try this

the simple way :)

Private Sub Command1_Click()
If Form2.Visible = True Then
'form is loaded
MsgBox ("Form 2 is loaded")
Else
MsgBox ("Form not loaded")
End If
End Sub

You can do that first by adding a public flag[do that in a module so you can access it anywhere], when form is loaded change it's value to 1. In button click if flag =1 then the form is loaded .

Private Sub Command1_Click()
If Flag = 1 Then
'form is loaded
MsgBox ("Form 2 is loaded")
Else
MsgBox ("Form not loaded")
End If
End Sub
Private Sub Command2_Click()
Form2.Show
End Sub

Change Flag when form2 closes

Private Sub Form_Load()
Flag = 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Flag = 0
End Sub

Edited 5 Years Ago by Vineeth K: n/a

thank you guys for the answers..Any way, both solutions just solved it..just a combination of setting the flag and form instances..

Thank You!

This question has already been answered. Start a new discussion instead.