0% found this document useful (0 votes)
31 views1 page

Table 3.1: Style Values and Command Buttons Style Value Named Constant Button Displayed

This document discusses using named constants instead of integers for the second argument in the MsgBox function in VBA to make code more readable. It shows a table mapping style values, named constants, and the buttons displayed for different MsgBox options. The document also explains that the MsgBox function returns a value to a variable based on which button the user clicks, and this return value must be declared as an Integer.

Uploaded by

Elmo Charles
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views1 page

Table 3.1: Style Values and Command Buttons Style Value Named Constant Button Displayed

This document discusses using named constants instead of integers for the second argument in the MsgBox function in VBA to make code more readable. It shows a table mapping style values, named constants, and the buttons displayed for different MsgBox options. The document also explains that the MsgBox function returns a value to a variable based on which button the user clicks, and this return value must be declared as an Integer.

Uploaded by

Elmo Charles
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

17

Table 3.1: Style Values and Command Buttons


Style Value Named Constant Button Displayed
0 vbOkOnly Ok button
1 vbOkCancel Ok and Cancel buttons
2 vbAbortRetryIgnore Abort, Retry and Ignore buttons.
3 vbYesNoCancel Yes, No and Cancel buttons
4 vbYesNo Yes and No buttons
5 vbRetryCancel Retry and Cancel buttons

We can use the named constant in place of integers for the second argument to
make the programs more readable. In fact, VBA will automatically show a list of
named constants where you can select one of them. For example,
yourMsg=MsgBox( "Click OK to Proceed", 1, "Startup Menu") and
yourMsg=Msg("Click OK to Proceed". vbOkCancel,"Startup Menu") are the
same. yourMsg is a variable that holds values that are returned by the MsgBox ( )
function. The values are determined by the type of buttons being clicked by the users.
It has to be declared as Integer data type in the procedure or in the general
declaration section. Table 3.2 shows the values, the corresponding named constants
and the buttons.

You might also like