excel vba - msgbox 是/否回复

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12047520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 17:24:11  来源:igfitidea点击:

excel vba - msgbox yes/no reply

excelvba

提问by HL8

I'm validating users input in userform. I have a msgbox prompt, with yesNo.

我正在验证用户表单中的用户输入。我有一个 msgbox 提示,是 yesNo。

If yes is clicked then just continue, if no is clicked I want the user to be able to go back to the userform to change the input/selection.

如果单击是,则继续,如果单击否,我希望用户能够返回到用户表单以更改输入/选择。

The code I've used is

我使用的代码是

 iReply = MsgBox(Prompt:="You have selected a month which is not next month. Do you want to continue? ", _
     Buttons:=vbYesNo, Title:="")
     If iReply = vbNo Then
        UserForm.Show
     End If

I get an error for "form already displayed cannot show modally" for UserForm.Show

对于 UserForm.Show,我收到“已显示的表单无法以模态显示”的错误消息

回答by Derek

The UserForm must be unloaded or hidden before it's loaded again. Try unloading using:

用户窗体在再次加载之前必须被卸载或隐藏。尝试卸载使用:

Unload UserForm

or hide it using

或使用隐藏它

UserForm.Hide