我想以编程方式决定用户是否点击了右上方" x"在visual basic中使用表单时按钮。
我试过了:
Private Sub nameOfForm_Exit()
'code goes here
End Sub
哪个不成功。任何帮助将不胜感激。
答案 0 :(得分:5)
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
答案 1 :(得分:3)