Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to exit sub of form1 using form2?
#1
Hi everybody
I have created a software and have added a form2 to it
In form1_closing event i have added the code
form2.showdialog
In form 2 i have added a button "Cancel"
I want that when the user press this cancel button then it exits the form_closing sub which prevents the software from Closing

Can anybody tell me How to Do it

Thanks in Advance!!!!
The Power to Believe in Yourself is the Power to change the Fate!
#2
So what you want to do is make it so when you press cancel on form2, form1 stops closing?
My Blog | My Setup | My Videos | Have a wonderful day.
#3
Yes ,You are Right!!
The Power to Believe in Yourself is the Power to change the Fate!
#4
Hm. Why do you want to do this? It seems really strange.
My Blog | My Setup | My Videos | Have a wonderful day.
#5
Actually i am creating a software like notepad
WHen you press the X button in Microsoft notepad you will see a form with a cancel button and when you press it the notepad stops closing

Thats why i want to know how to do it
The Power to Believe in Yourself is the Power to change the Fate!
#6
Well, you just need to pop something like this into your code!!

Code:
Public Sub GetUserPermission(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        Dim response As DialogResult
        response = MessageBox.Show("Do you really want to close?", "Really?", MessageBoxButtons.YesNoCancel) 'Show the message box
        If Not (response = Windows.Forms.DialogResult.Yes) Then
            'The user does not wish to close the form! Bail! Bail!!
            e.Cancel = True
        End If
    End Sub
My Blog | My Setup | My Videos | Have a wonderful day.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Exit code ? lvlasked 1 8,435 06-30-2011, 10:36 AM
Last Post: lvlasked

Forum Jump:


Users browsing this thread: 1 Guest(s)