MsgBox

Display a dialogue box message.

Syntax 
      MsgBox(prompt [, display][, title]
         [, helpfile, context])

Key
   prompt    The dialogue box text.
 
   display   The sum of the 4 constants for button, icon, default button and modality.

   title     Title bar text.

   helpfile  A helpfile to link to the help button.

   context   Helpfile context number.

Constants

  Button: vbOKOnly (0), vbOKCancel(1), vbAbortRetryIgnore (2), vbYesNoCancel(3)
           vbYesNo (4), vbRetryCancel (5)

  Icon: vbCritical (16),vbQuestion (32),vbExclamation (48), vbInformation (64) 

  Default button: vbDefaultButton1 (0),vbDefaultButton2 (256),vbDefaultButton3 (512),vbDefaultButton4(768)

  Modality: vbApplicationModal(0), vbSystemModal(4096)

SystemModal Message boxes will stay on top of any other window until dismissed. This makes them hard to ignore.

The terminology 'abort' is now considered archaic, it was largely used for error-prone floppy disks. Use cancel in preference.

The MsgBox function will return one of the following:

1 = OK was clicked (vbOK)
2 = Cancel was clicked (vbCancel )
3 = Abort was clicked (vbAbort)
4 = Retry was clicked (vbRetry)
5 = Ignore was clicked (vbIgnore)
6 = Yes was clicked (vbYes)
7 = No was clicked (vbNo)

Examples

Display a message:

result=Msgbox("Are you sure?",vbYesNo+vbInformation, "")
WScript.Echo result

“Everyone has an invisible sign hanging from their neck saying, Make me feel important. Never forget this message when working with people” ~ Mary Kay Ash

Related VBScript commands

InputBox - Prompt for user input.
PopUp - Display message for a limited time.
Equivalent PowerShell: MessageBox - Display a message box to the user.


 
Copyright © 1999-2026 SS64.com
Some rights reserved