【问题标题】:How do I check if a button is pressed in VBScript MsgBox? [duplicate]如何检查VBScript MSGbox中是否按下按钮[重复]
【发布时间】:2022-10-02 17:03:52
【问题描述】:

我如何能查看如果我单击 MSGbox 中的按钮?

x=msgbox(\"Test\" ,0+16, \"Test\") 

我的意思是查看不是如何制作消息框!

  • 请检查MsgBox 的返回值

标签: vbscript msgbox


【解决方案1】:
x = msgbox("Test" ,0+16, "Test")

if x = number then
    msgbox("Hello world")
end if

而不是 if 语句中的“数字”,写下与您想要检查是否按下的按钮相对应的数字。以下是您可以写的数字:

1 - 好的; 2 - 取消; 3 - 中止; 4 - 重试; 5 - 忽略; 6 - 是的; 7 - 没有

【讨论】:

  • 没有理由不使用命名常量,因为它们内置于 VBScript 中,正如 8 年前 here 所展示的那样。 - 见MsgBox Function
【解决方案2】:

这是一个例子:

 Dim AnswerQuestion,Msg,Title
 Title = "Answer the question ?"
 Msg = "Do you like cookies? ?"& Vbcr &_
     "If yes, then click [YES] button "& Vbcr &_
     "If not, then click [NO] button"
    
 AnswerQuestion = MsgBox(Msg,VbYesNo+VbQuestion,Title)
 If AnswerQuestion = VbYes then
    MsgBox "You clicked on OK Button Good, you're off the hook !",vbInformation,Title
 Else
    MsgBox "You clicked on No Button ! and You're going to jail !",VbCritical,Title
 End if

【讨论】:

  • 这是 8 年前的 been covered。该问题已被标记为重复,但您仍然忽略它。
猜你喜欢
  • 2020-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-25
  • 2021-11-18
  • 2011-05-11
  • 2020-08-24
  • 2020-06-28
相关资源
最近更新 更多