473,511 Members | 15,131 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application quit after button click

Hi ..

Can anyone please help me ?

Ik would like to raise a messagebox after the close-icon is clicked, asking
me if I'm sure to quit ...

I'm using this code ...

Private Sub myFormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

Dim intResult = MessageBox.Show("Are you sure to quit?", "Quit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1)

Select Case intResult
Case intResult.Yes
frmNext.Show() 'this form handles the quit
Me.Show()
End Select
End Sub

If i click on "no", the form hides itself, but the application is still
running ... bummer....

john
Aug 31 '06 #1
3 2595
Sorry, i forgot some line of code ...

I'm using this code ...

Private Sub myFormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

Dim intResult = MessageBox.Show("Are you sure to quit?", "Quit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1)

Select Case intResult
Case intResult.Yes
frmNext.Show() 'this form handles the quit
Case inResult.No
Me.Show()
End Select
End Sub

If i click on "no", the form hides itself, but the application is still
running ... bummer....

john
Aug 31 '06 #2
you need to use "Handles Me.FormClosing" instead of "Handles
Me.FormClosed"

John Devlon ha escrito:
Sorry, i forgot some line of code ...

I'm using this code ...

Private Sub myFormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

Dim intResult = MessageBox.Show("Are you sure to quit?", "Quit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1)

Select Case intResult
Case intResult.Yes
frmNext.Show() 'this form handles the quit
Case inResult.No
Me.Show()
End Select
End Sub

If i click on "no", the form hides itself, but the application is still
running ... bummer....

john
Aug 31 '06 #3
Hi John,

You need to write this code on 'Closing' event of the form instead of
writing on 'Closed' event. Here in 'closing' event you can cancel the
closing of the form just by using code of one line.

e.Cancel = True

This will cancel the closing event of the form.

Your code will look like this:

Private Sub myFormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.Closing

Dim intResult = MessageBox.Show("Are you sure to quit?", "Quit",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1)

if intResult = intResult.No then
e.Cancel = true 'Stops Closing of the Form
end if

End Sub

Regards,

Pragati Palewar

Palewar Techno Solutions
Windows Mobile & Palm Software Development
Nagpur, India

http://www.palewar.com

Sep 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4925
by: Lauren Quantrell | last post by:
Running Access2000 ADP Project/MSDE on Windows XP... - I Open my Access ADP project. In the Windows Task Manager Processes window MSACCESS.EXE shows up. - I don't do anything else in Access. - I...
8
2499
by: Eric | last post by:
How can I quit a smartdevice application ? After I click the right-hand(up) "X" button in the Pocket PC 2002 Emulator,it seems that the smartdevice application has not been closed. (My...
6
5276
by: Max | last post by:
I have the following code on a form that launches Microsoft Outlook and creates a new email message for the user: Outlook.Application oApp = new Outlook.Application(); Outlook.MailItem oMail...
3
4137
by: rdemyan via AccessMonster.com | last post by:
Sometimes users (including myself) accidentally click on the application close icon in the application menu bar when they meant to just click on the 'X' for the form. Of course the app closes and...
4
2105
by: mdmdmd | last post by:
Hello, I wish to collect 4 files from a user. So I have decided to use tkFileDialog askopenfilename. My problem is that after a few file selections the root window is destroyed (the whole...
1
1273
by: somtabu | last post by:
hello, i have a problem in vb.net windows application, verson is 2005 and framework is 2.0 I want to close a form by using the close button which is right hand top side of the window. i want,...
1
1116
by: SoNew | last post by:
I have designed a database and have used the following code to disable the standard Microsoft close button. I want my users to have to click on a Quit button on the switchboard: Private Sub...
2
2203
by: SoNew | last post by:
I have designed a database and have used the following code to disable the standard Microsoft close button. I want my users to have to click on a Quit button on the switchboard: Private Sub...
2
1543
by: loneranger | last post by:
Hi Everyone Visual Studio 2005 VB 2005 Windows Application I have a form with one combo box and a button I want the user to make a selection from the combo box, click the button and have...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.