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

Me.Close() does not terminate app

P: 2
Consider the following:
Expand|Select|Wrap|Line Numbers
  1.  Me.Hide()
  2.         frmSecond.ShowDialog()
  3.         If appCancelled Then
  4.             MessageBox.Show("Cancelled!")
  5.             Me.Close()
  6.         End If
frmSecond contains a "Cancel" button which sets appCancelled to "True". When the program runs, " Cancelled" is displayed by the MessageBox and appCancelled is in fact "True" but program falls right through. Replacinng Me.Close with End works fine but I don't like doing it this way!

Help/suggestions eagerly solicited!
Sep 1 '14 #1
Share this Question
Share on Google+
2 Replies


IronRazer
P: 82
Hi,
If you are trying to close your program from your 2nd form then use Application.Exit instead of Me.Close.

EDIT: I really can`t understand your explanation. Are you testing the Dialog result of the 2nd form in the main form upon the 2nd form closing? Maybe showing your code from the main form that opens the 2nd form and then show the code of your cancel button from your 2nd form would help understand what your doing. 8)
Sep 1 '14 #2

P: 2
The code in my question, "frmSecond.ShowDialog()" in particular, is what open the second form. Works fine. In the second form,

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
  2.         frmFirst.appCancelled = True
  3.         Me.Close()
  4.     End Sub
returns control to the first form. This works fine too.
Sep 1 '14 #3

Post your reply

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