Private Sub Form_QueryUnload(cancel As Integer, unloadmode As Integer)
The
unloadmode argument returns the following values:
Constant....................Description
vbFormControlMenu....The user chose the Close command from the Control menu on the form.
vbFormCode..............The Unload statement is invoked from code.
vbAppWindows...........The current Microsoft Windows operating environment session is ending.
vbAppTaskManager....The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm........An MDI child form is closing because the MDI form is closing.
vbFormOwner............A form is closing because its owner is closing.
- Код: Выделить всё
Private Sub Form_QueryUnload(cancel As Integer, unloadmode As Integer)
...
If unloadmode = vbFormControlMenu Then
tochno = msgbox("Do you really want to quit?", vbYesNo + vbQuestion, "Confirm")
If tochno <> vbYes Then
cancel = True
...