程序关闭之前的询问对话框

Option Explicit

Private Sub Form_Unload(Cancel As Integer)

 Dim Result As VbMsgBoxResult

 Result = MsgBox("是否退出?", vbQuestion + vbYesNo + vbDefaultButton1, "提示")

 If Result = vbNo Then Cancel = 1

End Sub