Me.Close() does not terminate app

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • edmini
    New Member
    • Sep 2014
    • 2

    Me.Close() does not terminate app

    Consider the following:
    Code:
     Me.Hide()
            frmSecond.ShowDialog()
            If appCancelled Then
                MessageBox.Show("Cancelled!")
                Me.Close()
            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!
    Last edited by Rabbit; Sep 1 '14, 05:45 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • IronRazer
    New Member
    • Jan 2013
    • 83

    #2
    Hi,
    If you are trying to close your program from your 2nd form then use Application.Exi t 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)

    Comment

    • edmini
      New Member
      • Sep 2014
      • 2

      #3
      The code in my question, "frmSecond.Show Dialog()" in particular, is what open the second form. Works fine. In the second form,

      Code:
      Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
              frmFirst.appCancelled = True
              Me.Close()
          End Sub
      returns control to the first form. This works fine too.
      Last edited by Rabbit; Sep 1 '14, 05:46 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.

      Comment

      Working...