0

Guyz, I want to know about the Form Disposed Event. I want that everytime I click the close button ("red X button located at the top right of the form") there will be a message box that asking if I want to exit, then if I click yes the programs ends then if I click No then nothing happens. I also call a function that deactivates the state of the User when I click Yes. The problem is when I click NO, the message box appears but the form has been disposed and the function I called was not execute..How will I do this? Help me guyz...
Here's my script...

Private Sub frmMain_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
        If MsgBox("Are you sure you want to exit?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Exit") = MsgBoxResult.Yes Then
            Call inactive()
            Application.Exit()
        Else
    
        End If
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Lee21
0

Handle formClosing event instead of disposed.

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If MsgBox("Are you sure you want to exit?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Exit") = MsgBoxResult.No Then
            e.Cancel = True
        End If
    End Sub
0

thanx a lot sir! you never let me down...
as always >>> Lee ^_^

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.