Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在用户关闭表单之前,我想用一个确认框进行提示。
我不知道该怎么做。我已经尝试了下面的代码,它会提示用户,但是单击“否”后它仍然会关闭表单:
Private Sub Form_Close() If MsgBox("Test", vbYesNo + vbExclamation, "Confirm close") = vbYes Then Else Cancel = True End If End Sub
您不能取消关闭事件,但可以取消卸载事件
Private Sub Form_Unload(Cancel As Integer) If MsgBox("Test", vbYesNo + vbExclamation, "Confirm close") <> vbYes Then Cancel = True End If End Sub