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.
CONSTANT | VALUE | DESCRIPTION |
VBOKONLY | 0 | Show OK button |
VBOKCANCEL | 1 | Show OK and cancel buttons |
VBABOrTRETRYIGNOrE | 2 | Show abort, retry, ignore buttons |
VBYESNOCANCEL | 3 | Show yes, no cancel buttons |
VBYESNO | 4 | Show yes, no buttons |
VBRETRYCANCEL | 5 | Show retry, cancel buttons |
VBCRITICAL | 16 | Show critical message icon |
VBQUESTION | 32 | Show warning query button |
VBEXCLAMATION | 48 | Show warning message icon |
VBINFORMATION | 64 | Show information message icon |
VBFAULTBUTTON1 | 0 | First button is default |
VBFAULTBUTTON2 | 256 | Second button is default |
VBFAULTBUTTON3 | 512 | Third button is default |
VBFAULTBUTTON4 | 768 | Fourth 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.