alert upon closing

SpiN9823
01-20-2004, 06:10 PM
how do i make an alert when you close the program that says "Are you sure you want to quit?"

VBJoe
01-20-2004, 10:39 PM
Use the Closing event:

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Microsoft.VisualBasic.MsgBox("Quit now?", MsgBoxStyle.YesNo, "Confirm Exit") = MsgBoxResult.No Then e.Cancel = True
End Sub

OnErr0r
01-20-2004, 10:55 PM
You can also use MessageBox.Show(), which is not part of Legacy Visual Basic backwards compatibility.

VBJoe
01-20-2004, 11:02 PM
Very cool. :)

I notice the MessageBox class' Show method has been overloaded 12 times. Man I love .NET... :D

OnErr0r
01-20-2004, 11:11 PM
Me Too! :)

SpiN9823
01-21-2004, 07:04 PM
thx VBJoe

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum