MsgBox関数では、ボタンの内容やアイコン等の組み合わせを定数で指定します。用途に応じて次のような定数を使うことができます。
表示時の設定内容 |
定数 |
実行結果 |
[OK]ボタンのみ |
vbOKOnly |
 |
[OK]ボタン、[キャンセル]ボタン |
vbOKCancel |
 |
[中止]ボタン、[再試行]ボタン、[無視]ボタン |
vbAbortRetryIgnore |
 |
[はい]ボタン、[いいえ]ボタン、[キャンセル]ボタン |
vbYesNoCancel |
 |
[はい]ボタン、[いいえ] |
vbYesNo |
 |
[再試行]ボタン、[キャンセル]ボタン |
vbRetryCancel |
 |
警告メッセージアイコン |
vbCritical |
 |
問い合わせメッセージアイコン |
vbQuestion |
 |
注意メッセージアイコン |
vbExclamation |
 |
情報メッセージアイコン |
vbInformation |
 |
第1ボタンをデフォルトボタンに設定 |
vbDefaultButton1 |
 |
第2ボタンをデフォルトボタンに設定 |
vbDefaultButton2 |
 |
第3ボタンをデフォルトボタンに設定 |
vbDefaultButton3 |
 |
返り値として選択されたボタン |
定数 |
[OK]ボタン |
vbOK |
[キャンセル]ボタン |
vbCancel |
[はい]ボタン |
vbYes |
[いいえ]ボタン |
vbNo |
[中止]ボタン |
vbAbort |
[再試行]ボタン |
vbRetry |
[無視]ボタン |
vbIgnore |
|