Tuesday, 22 August 2017

MSGBOX

MSGBOX:

The MsgBox function displays a message box, waits for the user to click a button, and returns a value that indicates which button the user clicked.      
                       MsgBox(prompt[,buttons][,title][,helpfile,context]) 


Parameter Description

·         Prompt - A Required Parameter. A String that is displayed as a message in the dialog box. The maximum length of prompt is approximately 1024 characters. 
·         buttons - An Optional Parameter. A Numeric expression that specifies the type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. If left blank, the default value for buttons is 0.
·         Title - An Optional Parameter. A String expression displayed in the title bar of the dialog box. If the title is left blank, the application name is placed in the title bar.
·         helpfile - An Optional Parameter. A String expression that identifies the Help file to use to provide context-sensitive help for the dialog box.
·         context - An Optional Parameter. A Numeric expression that identifies the Help context number assigned by the Help author to the appropriate Help topic. If context is provided, helpfile must also be provided.

Simply we can write above syntax as
MsgBox("Message you want to display in the box",Type of box/buttons you want to display,"Title of Box")
The Buttons parameter can take any of the following values which used to display different types of box.
·         0 vbOKOnly displays OK button only.
·         1 vbOKCancel displays OK and Cancel buttons.
·         2 vbAbortRetryIgnore displays Abort, Retry, and Ignore buttons.
·         3 vbYesNoCancel displays Yes, No, and Cancel buttons.
·         4 vbYesNo displays Yes and No buttons.
·         5 vbRetryCancel displays Retry and Cancel buttons.
·         16 vbCritical displays Critical Message icon.
·         32 vbQuestion displays Warning Query icon.
·         48 vbExclamation displays Warning Message icon.
·         64 vbInformation displays Information Message icon.
·         0 vbDefaultButton1 First button is default.
·         256 vbDefaultButton2 Second button is default.
·         512 vbDefaultButton3 Third button is default.
·         768 vbDefaultButton4 Fourth button is default.
·         0 vbApplicationModal Application modal. The current application will not work until the user responds to the message box.
·         4096 vbSystemModal System modal. All applications will not work until the user responds to the message box.
The above values are logically divided into four groups: The first group(0 to 5) indicates the buttons to be displayed in the message box. The second group (16, 32, 48, 64) describes the sytle of the icon to be displayed, the third group (0, 256, 512, 768) indicates which button must be the default, and the fourth group (0, 4096) determines the modality of the message box.

Ex: msgbox "Box Message",0,"Box Title"




msgbox "Box Message",3,"Box Title"


Change the "0" with any of these numbers above and check the output.

No comments:

Post a Comment