Solved

VB.NET Close Window Event (Basic stuff here)

Posted on 2007-03-19
4
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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