By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,159 Members | 1,941 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,159 IT Pros & Developers. It's quick & easy.

Determine if form is open?

P: n/a
Dear friends

Somebody an idea on this matter?

I have two forms in my app, form1 and form2

In form1 there is two buttons:
Private myForm2 AS New Form2
Private Sub Button1_Click...
myForm2.Show()
End Sub

Private Sub Button2_Click...
"Here I want to determine if Form2 is already open or not"
End Sub

Regards Able
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You could have x,000,000 instances of Form2 open at any time so I'm not sure
what that will do for you. If this is a MDI Scenario then you can loop
through the MDI Children and look for it though. Remember that Form2 is a
class not an instance.

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"able" <ab**@epost.no> wrote in message
news:s6****************@news2.e.nsc.no...
Dear friends

Somebody an idea on this matter?

I have two forms in my app, form1 and form2

In form1 there is two buttons:
Private myForm2 AS New Form2
Private Sub Button1_Click...
myForm2.Show()
End Sub

Private Sub Button2_Click...
"Here I want to determine if Form2 is already open or not"
End Sub

Regards Able

Nov 21 '05 #2

P: n/a
Able,

I don't like this sample I just made, however it seems to work.

Try it and I hope it helps?

Cor

\\\
Private WithEvents frm2 As Form2
Private Sub Button1_Click1(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If frm2 Is Nothing Then
frm2 = New Form2
frm2.Show()
End If
End Sub
Private Sub Button2_Click1(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button2.Click
If Not frm2 Is Nothing Then
MessageBox.Show("Hello I am open")
Else
MessageBox.Show("Hello I am closed")
End If
End Sub
Private Sub frm2_IsClosed() Handles frm2.IsClosed
frm2 = Nothing
End Sub
///
\\\
Friend Event IsClosed()
Private Sub Form2_Closed(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Closed
RaiseEvent IsClosed()
End Sub
///



Nov 21 '05 #3

P: n/a
Nice. Thanks.

Regards Able
"Cor Ligthert" <no************@planet.nl> skrev i melding
news:%2****************@TK2MSFTNGP09.phx.gbl...
Able,

I don't like this sample I just made, however it seems to work.

Try it and I hope it helps?

Cor

\\\
Private WithEvents frm2 As Form2
Private Sub Button1_Click1(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If frm2 Is Nothing Then
frm2 = New Form2
frm2.Show()
End If
End Sub
Private Sub Button2_Click1(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button2.Click
If Not frm2 Is Nothing Then
MessageBox.Show("Hello I am open")
Else
MessageBox.Show("Hello I am closed")
End If
End Sub
Private Sub frm2_IsClosed() Handles frm2.IsClosed
frm2 = Nothing
End Sub
///
\\\
Friend Event IsClosed()
Private Sub Form2_Closed(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Closed
RaiseEvent IsClosed()
End Sub
///


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.