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
Solved

VB.NET Close Window Event (Basic stuff here)

Posted on 2007-03-19
4
221 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Web Form VB.Net  import CSV 4 44
VB.NET (2008) - Refactoring Question 2 24
vb.net 1 month apart 11 35
Optimize the query 5 43
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

837 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