Finance

Charts

Statistics

Macros

Search

Buttons – An Overview in Excel VBA

The following examples in this section use various options to control the appearance and behavior of the dialog box.

Buttons Description
AbortRetryIgnore Three buttons: Abort, Retry, and Ignore
Critical Displays an icon that visually emphasizes a critical warning
DefaultButton1 (or 2/3) Specifies which button is activated when the user presses the Enter key — usually button 1
Exclamation Displays an icon with an exclamation mark to visually highlight a warning
Information Displays an information icon to visually highlight a simple message
Question Displays a question mark icon to visually indicate a question
RetryCancel Two buttons: Retry and Cancel
SystemModal Makes the dialog box stay on top, even if the user switches to another application
YesNo Two buttons: Yes and No
YesNoCancel Three buttons: Yes, No, and Cancel

You can combine a button set with an icon and a default button behavior using the Or operator. For example, you can combine AbortRetryIgnore with Exclamation and DefaultButton2. Alternatively, you can use the + operator instead of Or.

When multiple buttons are displayed, the return value of the MsgBox() function (i.e., the user’s choice) must be evaluated using conditional branching. This return value is an integer. To avoid memorizing these numbers, predefined constants are provided that represent them. Their names are self-explanatory: vbAbort, vbCancel, vbIgnore, vbNo, vbOK, vbRetry, and vbYes.

 

0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx