我想以編程方式確定用戶是否在Visual Basic中使用表單時單擊了右上方的「x」按鈕。確定用戶何時單擊x-VBA
我曾嘗試:
Private Sub nameOfForm_Exit()
'code goes here
End Sub
而一直未果。任何幫助將非常感激。
我想以編程方式確定用戶是否在Visual Basic中使用表單時單擊了右上方的「x」按鈕。確定用戶何時單擊x-VBA
我曾嘗試:
Private Sub nameOfForm_Exit()
'code goes here
End Sub
而一直未果。任何幫助將非常感激。
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
MsgBox "Good bye"
'/ To prevent user from closing the form
'/ Set cancel to True
Cancel = True
MsgBox "You can't close me!"
End Sub
QueryClose事件:https://msdn.microsoft.com/en-us/library/office/gg278635.aspx(甚至會告訴您用戶是否按下了X或者窗體是以編程方式關閉還是...等等,以及允許您防止表單關閉,如果您願意的話) – Mikegrann