「Excel VBA」メッセージボックスvbAbortRetryIgnoreのサンプル

環境
Windows 10 64bit
Excel 2013

使用例
MsgBox の引数
vbAbortRetryIgnore
[ 中止 ]、[ 再試行 ]、[ 無視 ] の各ボタン
vbOKCancel
[OK] ボタンと [キャンセル] ボタン

1.vbOKCancel(OKとキャンセルボタン)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Sub funA()
Dim nn As Integer
nn = MsgBox("welcome", vbOKCancel + vbInformation)
Debug.Print nn
End Sub
Sub funA() Dim nn As Integer nn = MsgBox("welcome", vbOKCancel + vbInformation) Debug.Print nn End Sub
Sub funA()
    Dim nn As Integer
    nn = MsgBox("welcome", vbOKCancel + vbInformation)
    Debug.Print nn
End Sub

実行結果
「OK」ボタンは1,「キャンセル」ボタンは2を返します

2.vbAbortRetryIgnore(中止、再試行、無視)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Sub funA()
Dim nn As Integer
nn = MsgBox("welcome", vbAbortRetryIgnore + vbInformation)
Debug.Print nn
End Sub
Sub funA() Dim nn As Integer nn = MsgBox("welcome", vbAbortRetryIgnore + vbInformation) Debug.Print nn End Sub
Sub funA()
    Dim nn As Integer
    nn = MsgBox("welcome", vbAbortRetryIgnore + vbInformation)
    Debug.Print nn
End Sub

実行結果
中止ボタンは3、再試行ボタンは4、無視ボタンは5を返します

3.vbOKCancel(OK、キャンセルボタン)

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Sub funA()
Dim nn As Integer
nn = MsgBox("welcome", vbOKCancel + vbInformation)
Debug.Print nn
End Sub
Sub funA() Dim nn As Integer nn = MsgBox("welcome", vbOKCancel + vbInformation) Debug.Print nn End Sub
Sub funA()
    Dim nn As Integer
    nn = MsgBox("welcome", vbOKCancel + vbInformation)
    Debug.Print nn
End Sub

実行結果
OKボタンは1、キャンセルボタンは2を返します。

Excel VBA

Posted by arkgame