DIAdem Help

Method: MsgBox for VBS

  • Updated2024-09-12
  • 2 minute(s) read

Method: MsgBox for VBS

Generates a message box.

vMsgBox = Object.MsgBox(prompt, [buttons], [title], [helpfile], [context])
ObjectVBS
Object with this method. You do not need to specify this object.
promptVariant
Specifies the text that displays in the dialog box. The maximum length depends on the width of the characters and is approximately 1024 characters.
[buttons]Variant
Specifies the number and type of buttons you want to display, the type of message field, the standard buttons, and the behavior of the message field. Possible settings for the number and type of buttons are vbOKOnly, vbOKCancel, vbAbortRetryIgnore, vbYesNoCancel, vbYesNo, and vbRetryCancel. Possible settings for the type of message field are vbCritical, vbQuestion, vbExclamation, and vbInformation. Possible settings for the standard buttons are vbDefaultButton1, vbDefaultButton2, vbDefaultButton3, and vbDefaultButton4. Possible settings for the behavior of the message box are vbApplicationModal, and vbSystemModal.
Assign, to the buttons value, the sum of the values for the number and type of the buttons you want to display, the type of message field, the standard button, and the behavior of the message field. For example, the value vbYesNo+vbQuestion results in a dialog box with a question mark and the buttons Yes and No.
If you do not specify a value, the MsgBox method displays a modal information dialog box with an OK button.
[title]Variant
Specifies the text for the title bar of the dialog box. If you do not enter a title, the MsgBox method displays the text VBScript in the title bar.
[helpfile]Variant
Specifies the path to a help file. The help file must be an HLP file. If you specify helpfile and context, the MsgBox method automatically adds the Help button to the dialog box.
[context]Variant
Specifies the ContextID of a help topic.
vMsgBoxVariant
Receives the pressed button. Possible return values are vbOK, vbCancel, vbAbort, vbRetry, vbIgnore, vbYes, and vbNo.

The following example displays a question and displays the selected button in an information message:

Dim MyVar, MySelection
MyVar = MsgBox("Do you like DIAdem?", vbYesNo + vbQuestion, "DIAdem")
Select Case MyVar
Case vbYes
    MySelection = "You choose Yes"
Case vbNo
    MySelection = "You choose No"
End Select
Call MsgBox(MySelection, vbInformation)

See Also

Objects Overview

Related Topics

InputBox | MsgBox