Connecting Tech Pros Worldwide Help | Site Map

how to close forms

Newbie
 
Join Date: Mar 2007
Posts: 28
#1: Apr 4 '07
I created a form and i inserted a close button.

I want to close this form and another form of the project when i clicked the button close.
I typed the following but the outside form doesn't close.
Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
frmTest.Close()
End Sub

can anyone help
vijaydiwakar's Avatar
Site Addict
 
Join Date: Feb 2007
Posts: 579
#2: Apr 4 '07

re: how to close forms


Quote:

Originally Posted by Stroumfs

I created a form and i inserted a close button.

I want to close this form and another form of the project when i clicked the button close.
I typed the following but the outside form doesn't close.
Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
frmTest.Close()
End Sub

can anyone help

this code is in the same form or it in \another form?
Newbie
 
Join Date: Mar 2007
Posts: 28
#3: Apr 4 '07

re: how to close forms


Quote:

Originally Posted by vijaydiwakar

this code is in the same form or it in \another form?

this code is in the same form. it closes with the me.close the form but i have the problem with the other form frmtest
vijaydiwakar's Avatar
Site Addict
 
Join Date: Feb 2007
Posts: 579
#4: Apr 4 '07

re: how to close forms


Quote:

Originally Posted by Stroumfs

this code is in the same form. it closes with the me.close the form but i have the problem with the other form frmtest

dear just revese the code close the other form first then close me
try it
Good Luck
Newbie
 
Join Date: Mar 2007
Posts: 28
#5: Apr 4 '07

re: how to close forms


i can close the form which have the button but i cant close the form which is outside.
vijaydiwakar's Avatar
Site Addict
 
Join Date: Feb 2007
Posts: 579
#6: Apr 4 '07

re: how to close forms


Quote:

Originally Posted by Stroumfs

i can close the form which have the button but i cant close the form which is outside.

what do u mean by outside?
pls clear
i've checked ur code and it require just a reversal order of execution
Newbie
 
Join Date: Mar 2007
Posts: 28
#7: Apr 4 '07

re: how to close forms


Quote:

Originally Posted by vijaydiwakar

what do u mean by outside?
pls clear
i've checked ur code and it require just a reversal order of execution

i reversed it but still is not working
vijaydiwakar's Avatar
Site Addict
 
Join Date: Feb 2007
Posts: 579
#8: Apr 4 '07

re: how to close forms


Quote:

Originally Posted by Stroumfs

i reversed it but still is not working

just check the code
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.         Form2.Show()
  5.     End Sub
  6.  
  7.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  8.         Form2.Close()
  9.         Me.Close()
  10.     End Sub
  11. End Class
  12.  
Newbie
 
Join Date: Mar 2007
Posts: 28
#9: Apr 4 '07

re: how to close forms


case close .thanks.
Reply