Msgboxes

Msgboxes

Message boxes are used when you want to ask the user a question or display an error message(s) and advise the user. There are six types of message boxes here are their functions and what they do. Here is the listing of all the possible msgbox events

The Buttons displayed in a message
 Button Layout       Value    Short Description

vbOKonly                  0         Displays the OK button.
vbOKCancel               1         Displays the ok and cancel button.
vbAbortRetryIgnore   2         Displays the Abort , Retry , Ignore
vbYesNoCancel          3         Displays Yes , No and Cancel button
vbYesNo                   4         Displays the Yes / No button
vbRetryCancel           5         Displays the retry and Cancel buttons.

The Icons dispayed in the message box are
 Icon on message Value Short Description

vbCritical               16    Displays critical message icon
vbQuestion            32    Displays question icon
vbExclamation        48    Displays exclamation icon
vbInformation        64    Displays information icon

The Default button displayed in a message form
 Default Button    Value    Short Description
vbDefaultButton1    0       Button 1 is default
vbDefaultButton2   256    Button 2 is default
vbDefaultButton3   512    Button 3 is default

Msgbox Return Value
  Return Value  Value  Short Description
vbOk                 1      The User Clicked OK
vbCancel            2      The User Clicked Cancel
vbAbort             3      The User Clicked Abort
vbRetry             4      The User Clicked Retry
vbIgnore            5      The User Clicked Ignore
VbYes                6      The User Clicked Yes
VbNo                 7      The User Clicked No
The syntax for use of the message box in Mgsgbox “TEXT”, VALUE, “TITLE”
If you want to use two or more tables just add the values together. Therefore to print a message box to say “All fields are mandatory!” OK & Explanation :

Source code 1

Private Sub Form_Load()

MsgBox “All fields are mandatory!”, 48, “Header”

End Sub

Source code 2

Private Sub Form_Load()

MsgBox “All fields are mandatory!”, vbExclamation, “Header”

End Sub

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.