How do I check if a button is pressed in VBScript MSGbox

Viewed 45

How do I check if I click on a button in MSGbox?

x=msgbox("Test" ,0+16, "Test") 
2 Answers
x = msgbox("Test" ,0+16, "Test")

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

instead of the "number" in the if statement, write the number coresponding with the button that you want to check if pressed. Here are the numbers that you can write:

1 - ok; 2 - cancel; 3 - abort; 4 - retry; 5 - ignore; 6 - yes; 7 - no


Here is an example :

 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
Related