Create Message box/ pop up message

我是研究僧i 提交于 2020-01-14 05:50:09

问题


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?


回答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.




回答2:


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

Description:

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



回答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


来源:https://stackoverflow.com/questions/18804267/create-message-box-pop-up-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!