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

how to close forms

P: 28
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
Apr 4 '07 #1
Share this Question
Share on Google+
8 Replies


vijaydiwakar
100+
P: 579
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?
Apr 4 '07 #2

P: 28
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
Apr 4 '07 #3

vijaydiwakar
100+
P: 579
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
Apr 4 '07 #4

P: 28
i can close the form which have the button but i cant close the form which is outside.
Apr 4 '07 #5

vijaydiwakar
100+
P: 579
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
Apr 4 '07 #6

P: 28
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
Apr 4 '07 #7

vijaydiwakar
100+
P: 579
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.  
Apr 4 '07 #8

P: 28
case close .thanks.
Apr 4 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.