Solved

VB.NET Close Window Event (Basic stuff here)

Posted on 2007-03-19
4
218 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
Comment Utility
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
Comment Utility
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
Comment Utility
sirbounty,

Thanks for the code example!

Andrew
0
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
Happy to help - thanx for the grade!  :^)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 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

10 Experts available now in Live!

Get 1:1 Help Now