Solved

VB.NET Close Window Event (Basic stuff here)

Posted on 2007-03-19
4
219 Views
Last Modified: 2012-05-05
I have a VB.NET app with many forms, for this example I will use Form1

When the user clicks the red X (top right) I want to fire an event that pops up a message asking the user if they want to save, if yes, then fire SubA, if no then fire SubB.

Thanks
0
Comment
Question by:Crazy_Penguins
  • 3
4 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18752679
I believe you'll want to do this in the FormClosing event...

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  Dim strResp As String=MessageBox.Show("Do you want to save?","Save changes?", MessageBoxButtons.YesNo)
  If strResp=vbYes Then SubA
  SubB
End Sub
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 500 total points
ID: 18752681
http://www.codeproject.com/vb/net/appsettings2005.asp?df=100&forumid=234082&exp=0&select=1291168 details this with application settings upon closing the form...
0
 

Author Comment

by:Crazy_Penguins
ID: 18754068
sirbounty,

Thanks for the code example!

Andrew
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18755224
Happy to help - thanx for the grade!  :^)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now