Molto probabilmente intende in questo modo:
codice:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case UnloadMode
Case vbFormCode, vbAppTaskManager, vbAppWindows
'ok, chiudere
Case Else
MsgBox "Non possibile chiudere applicazione", vbInformation, "Attenzione"
Cancel = True
WindowState = vbMinimized
End Select
End Sub
Il parametro UnloadMode può assumere i seguenti valori:
Constant Value Description
vbFormCode 1 Unload method invoked from code.
vbAppWindows 2 Current Windows session ending.
vbFormMDIForm 4 MDI child form is closing because the MDI form is closing.
vbFormControlMenu 0 User has chosen Close command from the Control-menu
box on a form.
vbAppTaskManager 3 Windows Task Manager is closing the application.
Non è allineato molto bene ma si dovrebbe capire ugualmente, ciao.