Quote Originally Posted by abhijit
I tried putting some code over here. For windows shut-down, but that did not work.

VB Code:
  1. Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
  2.  
  3.         If osexit Then
  4.             'Not doing anything will let the application close
  5.             e.Cancel = True 'A windows shutdown will not shut down the app.
  6.  
  7.         Else
  8.             Dim sure
  9.             sure = MsgBox("Are you sure you want to terminate the application", MsgBoxStyle.Critical + MsgBoxStyle.YesNo)
  10.             If sure = vbYes Then
  11.                 Application.Exit()
  12.             Else
  13.                 e.Cancel = True 'This will cause the application to ignore the close & continue running
  14.                 'Me.Hide()
  15.             End If
  16.         End If
  17.     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.