MsgBox vbscript Tutorial


SUBMITTED BY: klook69

DATE: March 8, 2018, 9:38 a.m.

FORMAT: Text only

SIZE: 2.4 kB

HITS: 777

  1. How to use MsgBox with vbscript
  2. Syntax:
  3. MsgBox(Prompt, Buttons, Title)
  4. Prompt
  5. The Prompt argument is the message string that appears in the message box.
  6. Buttons
  7. The optional Buttons argument must only use the constant or value in the MsgBox CONSTANTS.
  8. Title
  9. The optional Title argument is the title that appears at the top of the message box window.
  10. Note you may use either the Title argument or the HelpFile, Context arguments. You cannot use both at the same time.
  11. HelpFile
  12. 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.
  13. Note you may use either the Title argument or the HelpFile, Context arguments. You cannot use both at the same time.
  14. Context
  15. 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.
  16. 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.
  17. MsgBox Return Values
  18. CONSTANT VALUE BUTTON
  19. VBOK 1 OK
  20. VBCancel 2 Cancel
  21. VBAbort 3 Abort
  22. VBRetry 4 Retry
  23. VBIgnore 5 Ignore
  24. VBYes 6 Yes
  25. VBNo 7 No
  26. MsgBox Button Constants
  27. CONSTANT VALUE DESCRIPTION
  28. VBOKOnly 0 Show OK button
  29. VBOKCancel 1 Show OK and cancel buttons
  30. VBAbortRetryIgnore 2 Show abort, retry, ignore buttons
  31. VBYesNoCancel 3 Show yes, no cancel buttons
  32. VBYesNo 4 Show yes, no buttons
  33. VBRetryCancel 5 Show retry, cancel buttons
  34. VBCritical 16 Show critical message icon
  35. VBQuestion 32 Show warning query button
  36. VBExclamation 48 Show warning message icon
  37. VBInformation 64 Show information message icon
  38. VBDefaultButton1 0 First button is default
  39. VBDefaultButton2 256 Second button is default
  40. VBDefaultButton3 512 Third button is default
  41. VBDefaultButton4 768 Fourth button is default
  42. VBApplicationModal 0 Demands that the user respond to the dialog before allowing continuation of work in current application
  43. VBSystemModal 4096 Causes suspension of all applications until the user responds to the dialog

comments powered by Disqus