Try:
Private m_frmForm2 As Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If m_frmForm2 Is Nothing Then ' First time
m_frmForm2 = New Form2()
m_frmForm2.Show()
ElseIf m_frmForm2.IsDisposed Then ' The form was closed
m_frmForm2 = New Form2()
m_frmForm2.Show()
Else
m_frmForm2.Activate()
End If
End Sub
--
Carlos J. Quintero (Visual Developer - .NET MVP)
The MZ-Tools all-in-one add-in, now for .NET:
http://www.mztools.com
"Kishan Hathiwala" <ki****@hathiwala.fateback.com> escribió en el mensaje
news:u0**************@TK2MSFTNGP11.phx.gbl...
Hi
just study the following code...
i have kept a command button and on its click event i have written the
following code:
(assume that there are two forms- form1 and form2 and command button is on
form1)
dim frm as new form2
frm.show
now everytime i click on this button new instance of form2 is created.
now the question is whenever i click that button i dont want to create new
instance always when its already created, i just want that form to be
active whether its hidden or active.
thanks
K