Close One Form From Another

larkahn

Member
Joined
Sep 10, 2006
Messages
18
Programming Experience
1-3
My main form is Dictionaryfrm. I have a button on this form to call an instance of another form. What I would like to do is as a first step, close or hide the MyIPA by clicking a button from the first form (Dictionaryfrm).

VB.NET:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

[INDENT] Dim MyIPA As New IPAfrm
 MyIPA.Show()
[/INDENT]End Sub

Any assistance would be appreciated. I have limited programming skills.
 
1 way of doing this (this might be not the best way)

Private MyIPA As IPAfrm = nothing

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
if MyIPA is nothing then
MyIPA = new IPAFrm
MyIPA.Show()
else
MyIPA.Show()
end if
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
if MyIPA is nothing = false then
MyIPA.Hide()
end if
End Sub
 
Thank you. This seemed to work quite easily. In fact I was able to combine the code into one button to turn it into a toggle button to hide/show the second form. I appreciate this simple version.
 
Back
Top