I have the following code in a command button in form1:
How can i close form2 using a command button on form1?Code:Dim frm As New Form2()
frm.Close()
Printable View
I have the following code in a command button in form1:
How can i close form2 using a command button on form1?Code:Dim frm As New Form2()
frm.Close()
You can't, unless you have access to an instance of it.
Is form2 loaded by form1?
yes, i believe in the form1.load, i have a form2.show()
If I didn't get it wrongly :cool: then do this :
declare a variable in the general declaration of Form1
dunno if you mean that ???:rolleyes:VB Code:
Dim frm2 As New Form2() Private Sub show_form2_Click(ByVal sender As System.Object,_ ByVal e As System.EventArgs) Handles show_form2.Click frm2.Show() End Sub Private Sub close_form2_Click(ByVal sender As System.Object,_ ByVal e As System.EventArgs) Handles close_form2.Click frm2.Close() End Sub