Create Message box/ pop up message

31,605

Solution 1

You can't. Alert takes just a single parameter: the message to display. If you want to control the icon and/or buttons you must use a MsgBox or build your own custom dialog.

Solution 2

X=MsgBox ("hello",48, " ")

Description:

X=MsgBox ("your message",(button options) ,"title")

Solution 3

I know this post is a little old, but I stumbled upon it looking for something else. Since I am here....

I keep this little VBScript handy for any time I use a msgBox and can't think of the responses of the top of my head. You want Yes/No, OK/Cancel, Abort/Retry/Cancel....? Just paste this into a .VBS file with notepad for future reference.

Edit the file to see what button syntax you or looking for, or double-click the VBS to see how each of them work.

Enjoy!

Sample = msgBox("Option codes 0+64." & vbCrLf & vbCrLf & "This is an information situation with OK only",0+64, "Information.")
    Select Case Sample
        Case 1
            wScript.Echo "You acknowledged."
    End Select

Sample = msgBox("Option codes 1+48." & vbCrLf & vbCrLf & "This is a warning situation with OK and Cancel",1+48, "WARNING!")
    Select Case Sample
        Case 1
            wScript.Echo "You chose OK."
        Case 2
            wScript.Echo "You chose Cancel."
    End Select

Sample = msgBox("Option codes 2+16." & vbCrLf & vbCrLf & "This is a critical situation with Abort, Retry, and Ignore",2+16, "CRITICAL!")
    Select Case Sample
        Case 3
            wScript.Echo "You chose Abort."
        Case 4
            wScript.Echo "You chose Retry."
    Case 5
        wScript.Echo "You chose Ignore."
    End Select

Sample = msgBox("Option codes 0+16." & vbCrLf & vbCrLf & "This is a critical error situation with OK only",0+16, "CRITICAL ERROR!")
    Select Case Sample
        Case 1
            wScript.Echo "You acknowledged."
    End Select

Sample = msgBox("Option codes 3+32." & vbCrLf & vbCrLf & "This is a question situation with Yes, No, or Cancel",3+32, "Question?")
    Select Case Sample
        Case 6
            wScript.Echo "You said Yes."
        Case 7
            wScript.Echo "You said No."
        Case 2
            wScript.Echo "You clicked Cancel."
    End Select

Sample = msgBox("Option codes 4+32." & vbCrLf & vbCrLf & "This is a question situation with Yes or No only",4+32, "Question?")
    Select Case Sample
        Case 6
            wScript.Echo "You said Yes."
        Case 7
            wScript.Echo "You said No."
    End Select

Sample = msgBox("Option codes 5+16." & vbCrLf & vbCrLf & "This is a critical error situation with Retry or Cancel",5+16, "CRITICAL ERROR!")
    Select Case Sample
        Case 4
            wScript.Echo "You clicked Retry."
        Case 2
            wScript.Echo "You clicked Cancel."
    End Select
Share:
31,605
user2689288
Author by

user2689288

Updated on February 15, 2022

Comments

  • user2689288
    user2689288 over 2 years

    See these message box images

    1: http://catalinx.homeftp.org/img/Autoiterror1.jpg 2: http://www.exceltrick.com/wp-content/uploads/2013/02/Messagebox-Example-5.png

    I can create such messagebox using vbs in a notepad as shown in 1st image. But click buttons are like in 2nd image. How to solve it? I'm making an HTA app.

    I'm asking how to add particular set of buttons in new style. For example see 2 methods:

    MsgBox "Hello", 48
    

    and

    Alert "Hello"
    

    Both displays same thing with Exclamation. But the style of OK button is different. If we use the 2nd, it is more beautiful than 1st. So i would like to add a cancel buttons to the 2nd method as below

    Msgbox "Hello",17
    

    How?

    • Teemu
      Teemu almost 11 years
      window has also confirm() method, though it shows a questionmark instead of exclamation...
  • user2689288
    user2689288 almost 11 years
    Ansgar Wiechers, I've updated question. I hope you can now understand my topic clearly.