MS Access 2003 - 消息框:如何回答“确定”通过代码自动
所以有几个愚蠢的问题:
如果我在某些事件中包含此内容:
MsgBox " ", vbOkOnly, "This little message box"
然后我可以使用更多代码然后“单击确定”按钮吗?那么基本上消息框会自动弹出,然后自动消失吗?
我知道这很愚蠢,因为你想知道,为什么你想要消息框......
好吧a)我只是想知道你是否可以做到这一点,以及命令是什么
b)我有一些基本形状(形状对象)当消息框出现时可见。但是,如果没有消息框,则在等待单击按钮时不会暂时中断代码,因此那些可见的漂亮图像对象确实会在表单上生效。
所以我真的不需要消息框,只需要显示对象的临时中断。
谢谢!
So a couple silly questions:
If I include this in some event:
MsgBox " ", vbOkOnly, "This little message box"
could I then with some more code turn around and 'click the ok button. So that basically the message boox automatically pops up, and then automatically goes away?
I know its silly because you want to know, why do you want the message box then.....
well a) i just want to know if you can do that, and what would be the command
b) i have some basic shapes (shape objects) that are made visible when the message box appears. But without having the message box there, there is no temporary disruption of code while waiting for the button to be clicked, and therefor those pretty image objects being made visible does take effect on the the form.
So I really do not need the message box, just the temp disruption that shows the objects.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
MsgBox
是模态的。只有两个与 Modality 相关的设置因此,如果您当前的应用程序弹出 Msgbox,则在单击消息框上的按钮之前不会运行任何代码。
解决这个问题的方法是使用表单设计您自己的消息框。您可以弹出它并保持打开状态,然后您可以“单击”它上面的任何按钮。
如果你想要延迟,可以使用Win API来休眠
A
MsgBox
is Modal. There are only two Modality related settingsSo if the Msgbox is popped up by your current application, no code will run until you click a button on the message box.
The way to get around this is to design your own message box using a form. You can pop this up and keep it on and then you can "click" any button you want on it.
If you want a delay, you can use the Win API to sleep
我知道不久前有人问过这个问题,但我使用的解决方案是这样的:
这是如何工作的,消息框的显示方式与普通消息框一样,但是它有自己的系统计时器,这意味着您甚至可以自动关闭消息框,而无需执行任何操作任何事物。
数字 1 表示您希望它在自动关闭之前显示多少秒。
我将其用于保存过程,因为它是一个有用的通知,表明某些内容已保存,但不需要用户实际单击“确定”。
无论如何,这是我的两便士价值的答案。希望这也对其他人有帮助!
I know this was asked a while ago but the solution I use is this:
How this works is a message box is displayed just as a normal one would however it has its own system timer which means you can auto close the message box without even doing anything.
The number 1 signifies how many seconds you want it to show for before closing automatically.
I use this for save procedures as its a useful notification that something has saved but does not require the user to actually click "OK".
Anyway that is my two pennies worth of an answer. Hope this helps someone else too!
应该关闭消息框(假设它有焦点)
我认为您正在寻找绘画事件,或者强制刷新表单以实现您真正想要做的事情!
编辑:啊该死,是的,因为它是模态的,所以代码被挂起......天啊!正如建议的那样,要么自己编写,要么必须在另一个线程中扔一些东西来完成它,而且我不知道如何在 MS Access 中进行多线程!
第二次编辑:您是否查看过
Application.Echo False
来暂停和Application.Echo True
来恢复绘画布局?Should dismiss the msgbox (assuming it has focus)
I think you're looking for the paint events, or forcing a form refresh though to achieve what you actually want to do!
Edit: Ah damn, yeah, because it's modal the code is suspended... d'oh! As suggested, either write your own, or you'd have to throw something in another thread to do it, and I have no idea how to do multi threading in MS Access!
Second Edit: Have you looked at
Application.Echo False
to suspend andApplication.Echo True
to resume painting layout?