Elipse Knowledgebase



Basic VBScript for Elipse E3: Lesson 1 - Message Box

A Message Box displays a dialog box and expects the user to click on a button, returning an indicator value from the clicked button.


Figure 1

The syntax is the following:

MsgBox(Message, Buttons, Title)

Where:
Message: Text that is going to be displayed on the dialog box
Buttons: See table below
Title: Message Box title

BUTTONS
 CONSTANT VALUE DESCRIPTION
 vbOKOnly  0 Displays the OK button
 vbOKCancel  1 Displays OK and Cancel buttons
 vbAbortRetryIgnore  2 Displays Abort, Retry, and Ignore buttons
 vbYesNoCancel  3 Displays Yes, No, and Cancel buttons
 vbYesNo  4 Displays  Yes and No buttons
 vbRetryCancel  5 Displays  Retry  and Cancel buttons
 VbCritical  16 Displays Critical icon
 vbQuestion  32 Displays Question icon
 vbExclamation  48 Displays Exclamation icon
 vbInformation  64 Displays Information icon
 vbDefaultButton1  0 Sets 1st  button as default
 vbDefaultButton2  256  Sets 2nd button as default
 vbDefaultButton3  512  Sets 3rd button as default
 vbDefaultButton4  768  Sets 4th button as default
 vbApplicationModal  0 Modal Application. The user must respond to the Message Box before continuing working in the application.
 vbSystemModal  4096  Modal System. All applications are suspended until the user responds to the Message Box. 

The MsgBox function returns the following values:

VALUES
 CONSTANT VALUE DESCRIPTION
 vbOK  1 OK
 vbCancel  2 Cancel
 vbAbort  3 Abort
 vbRetry  4 Retry
 vbIgnore  5 Ignore
 vbYes  6 Yes
 vbNo  7 No

For the example in Figure 1, we wrote the following code line:

MsgBox "Message Text", vbAbortRetryIgnore + vbCritical, "Message title"

If you wish to keep the user's answer, the function parameters must be between parentheses:

'Question
resp = MsgBox("Message text", vbAbortRetryIgnore + vbCritical, "Message title")
'Answer
MsgBox "The user answered" & resp

Exercises:

1. Write the code for the following dialog boxes:


Figure 2


Figura 3

2. Write the code for the following dialog boxes and display on a second message the user's answer.


Figure 4


Figure 5


Related Articles

Attachments

Visitor Comments

No visitor comments posted. Post a comment

Post Comment for "Basic VBScript for Elipse E3: Lesson 1 - Message Box"

To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.

   Name:
   Email:
* Comment:
* Enter the code below:

 

Article Details

Last Updated
3rd of January, 2012

Autor
Paula Pereira Enéas

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit


User Opinions

100% thumbs up 0% thumbs down (3 votes)

How would you rate this answer?




Thank you for rating this answer.

Continue