用户窗体关闭事件 [英] UserForm Close Event

查看:24
本文介绍了用户窗体关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户窗体,它在条件存在时循环打开和关闭.用户可以单击多个按钮来执行操作.问题在于用户的不可预测性.这些问题之一是,用户不是单击其中一个按钮,而是单击用户窗体顶部的关闭窗口按钮,这会在不执行任何操作的情况下进行循环.

I have a UserForm which is opened and closed in a loop while a condition exists. The users can click several buttons which performs an action. The problem is the unpredictability of users. One of those problems is, users, instead of clicking one of the buttons, clicking the close window button on top of the UserForm which progresses the loop without performing an action.

---编辑---
是否有一个带有该按钮的事件,我可以用它来执行代码,以便我可以让它执行与表单本身上的取消按钮相同的操作.我不需要隐藏或禁用它本身.

--- edit---
Is there an event with that button with which I can execute code so that I can let it perform the same action as the cancel button on the form itself. I do not need to hide or disable it per se.

推荐答案

例如,您可以将下面的宏添加到 UserForms 代码模块中:

For example, you can add the macro below to the UserForms code module:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then
        Cancel = True
        MsgBox "You can't close the dialog like this!"
    End If
End Sub

这篇关于用户窗体关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆