|
-
Jun 16th, 2005, 06:37 AM
#9
Re: Form_QueryUnload in vb.net
 Originally Posted by abhijit
I tried putting some code over here. For windows shut-down, but that did not work.
VB Code:
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If osexit Then
'Not doing anything will let the application close
e.Cancel = True 'A windows shutdown will not shut down the app.
Else
Dim sure
sure = MsgBox("Are you sure you want to terminate the application", MsgBoxStyle.Critical + MsgBoxStyle.YesNo)
If sure = vbYes Then
Application.Exit()
Else
e.Cancel = True 'This will cause the application to ignore the close & continue running
'Me.Hide()
End If
End If
End Sub
Help,
Abhijit
Like I said, that code will never be executed. The only place that osexit gets set to True calls Application.Exit on the next line. Application.Exit shuts down the app without raising any Form.Closing events, so the event handler containing your new bit of code is not called.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|