All Functions
InputBox Function
FUNCTION: MsgBox( )
Implemented in version 1.0
MsgBox
(Prompt,
Buttons, Title
)
MsgBox
(Prompt,
Buttons, HelpFile, Context
)
The
MsgBox
function creates a dialog box with a specified message and prompts the user to click a button, upon which the dialog box closes and a value relating to which button was clicked is returned. These values, along with their Constants, are listed in the table below.
CONSTANT
VALUE
BUTTON
VBOK
1
OK
VBCancel
2
Cancel
VBAbort
3
Abort
VBRetry
4
Retry
VBIgnore
5
Ignore
VBYes
6
Yes
VBNo
7
No
Click on the buttons to see a display of the various available types of Message Box.
OK
OK, Cancel
Abort, Retry, Ignore
Yes, No, Cancel
Yes, No
Retry, Cancel
Critical OK
Warning Query OK
Warning Message OK
Info OK
Warning Query, Abort, Retry, Cancel
There is one mandatory argument.
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
VBDefaultButton1
0
First button is default
VBDefaultButton2
256
Second button is default
VBDefaultButton3
512
Third button is default
VBDefaultButton4
768
Fourth button is default
VBApplicationModal
0
Demands that the user respond to the dialog before allowing continuation of work in current application
VBSystemModal
4096
Causes suspension of all applications until the user responds to the dialog
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
The optional
HelpFile
argument is a string that specifies the help file that you wish to display. This must be either a .chm or .hlp file.
Context
The optional
Context
argument specifies the help context number in the help file of the topic you wish to display. If you have created your own custom help file, then the
Context
argument is mandatory.
Code:
MsgBox "Date is not valid", vbMsgBoxHelpButton, "help_folder/date_help_file.hlp", 71
Output:
Not demonstrated.
Copyright 1999-2004 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information