ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods






FUNCTION:  MsgBox( )

MsgBox(Prompt, Buttons, Title)

MsgBox(Prompt, Buttons, HelpFile, Context)

The MsgBox function creates message box buttons.

Click on the buttons to see a display of the various types of Message Box Buttons.

OK
OK, Cancel
Abort, Retry, Ignore
Yes, No, Cancel
Yes, No
Retry, Cancel

Critical OK
Warning Query OK
Warning Message OK
Info O
Warning Query, Abort, Retry, Cancel


There is one mandatory arguments.

Prompt

The Prompt argument is the message string that appears in the message box.

The default message box is the OK.

Code:
< INPUT TYPE="BUTTON" NAME="button0" VALUE="Click Here!" >

< SCRIPT LANGUAGE="VBScript" >
Sub button0_onclick
   MsgBox "Please Click OK"
End Sub
< /SCRIPT >

Output:


There are four optional arguments.

Buttons

The optional Buttons argument must only use the constant or value in the MsgBox CONSTANTS.

CONSTANTVALUEDESCRIPTION
VBOKONLY0Show OK button
VBOKCANCEL1Show OK and cancel buttons
VBABOrTRETRYIGNOrE2Show abort, retry, ignore buttons
VBYESNOCANCEL3Show yes, no cancel buttons
VBYESNO4Show yes, no buttons
VBRETRYCANCEL5Show retry, cancel buttons
VBCRITICAL16Show critical message icon
VBQUESTION32Show warning query button
VBEXCLAMATION48Show warning message icon
VBINFORMATION64Show information message icon
VBFAULTBUTTON10First button is default
VBFAULTBUTTON2256Second button is default
VBFAULTBUTTON3512Third button is default
VBFAULTBUTTON4768Fourth button is default

Code:
< INPUT TYPE="BUTTON" NAME="button_1" VALUE="Click Here!"> >

< SCRIPT LANGUAGE="VBScript" >
Sub button_1_onclick
   MsgBox "Please Click OK", VBOKCANCEL
End Sub
< /SCRIPT >

Output:

Note you may use either the Title argument or the HelpFile, Context arguments. You cannot use both at the same time.

Title

The optional Title argument is the title that appears at the top of the message box window.

Code:
< INPUT TYPE="BUTTON" NAME="button_2" VALUE="Click Here!"> >

< SCRIPT LANGUAGE="VBScript" >
Sub button_2_onclick
   MsgBox "Please Click!", VBRETRYCANCEL, "MsgBox Demo"
End Sub
< /SCRIPT >

Output:

HelpFile, Context

The optional HelpFile argument specifies the location of the help file.

The optional Context argument specifies the help context number in the help file.

Not demonstrated.