1 Replies - 1452 Views - Last Post: 01 November 2009 - 08:42 AM Rate Topic: -----

#1 kumaraj  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 80
  • Joined: 12-February 09

Make A Message Box When An Application Exits

Posted 01 November 2009 - 08:35 AM

I've made an application in Visual Basics, But I Want A msgbox to appear when the form is closed
would this work?
	Private Sub Form1_OnExit(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.OnExit
		MsgBox("Have You Saved, If Not Your Work WILL Be Discarded!", MsgBoxStyle.Critical, "Have You Saved?")
	End Sub


It keeps coming up with an error, why? And How Do I Fix It? I would appreciate any help that I receive, Thanks!!!

This post has been edited by kumaraj: 01 November 2009 - 08:37 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Make A Message Box When An Application Exits

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1726
  • View blog
  • Posts: 5,704
  • Joined: 25-September 09

Re: Make A Message Box When An Application Exits

Posted 01 November 2009 - 08:42 AM

I always put this in the form1_FormClosing event
dim ans as integer = MessageBox.Show("If you have not saved your work, all changes will be lost","Are you sure you want to exit?",MessageBoxButtons.YesNo)
		If ans = DialogResult.No Then
			e.Cancel = True
		End If


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1