How to cancel the unload event of a form? I have this code in vb 6 and it is working:
[CODE=vb]
Private Sub Form_QueryUnloa d(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Are you sure you want to exit system?", vbYesNo, "Exit System") = vbYes Then
Unload Me
Else
Cancel = 1
End If
End Sub
[/CODE]
I converted the codes to vb .net but I failed to make it:
[CODE=vb.net]Private Sub frmMain_FormClo sing(ByVal sender As Object, ByVal e As System.Windows. Forms.FormClosi ngEventArgs) Handles Me.FormClosing
If MessageBox.Show ("Are you sure you want to exit system?", "Exit System", MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = Windows.Forms.D ialogResult.Yes Then
Global.System.W indows.Forms.Ap plication.Exit( )
Else
Exit Sub
End If
End Sub[/CODE]
Rey Sean
[CODE=vb]
Private Sub Form_QueryUnloa d(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Are you sure you want to exit system?", vbYesNo, "Exit System") = vbYes Then
Unload Me
Else
Cancel = 1
End If
End Sub
[/CODE]
I converted the codes to vb .net but I failed to make it:
[CODE=vb.net]Private Sub frmMain_FormClo sing(ByVal sender As Object, ByVal e As System.Windows. Forms.FormClosi ngEventArgs) Handles Me.FormClosing
If MessageBox.Show ("Are you sure you want to exit system?", "Exit System", MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = Windows.Forms.D ialogResult.Yes Then
Global.System.W indows.Forms.Ap plication.Exit( )
Else
Exit Sub
End If
End Sub[/CODE]
Rey Sean
Comment