「Excel VBA」メッセージボックスのタイトル、ボタンを表示するサンプル

2021年7月27日

1.メッセージボックスのタイトル

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Sub funcA()
MsgBox("hello", vbOKCancel + vbInformation, "test title")
End Sub
Sub funcA() MsgBox("hello", vbOKCancel + vbInformation, "test title") End Sub
Sub funcA()
    MsgBox("hello", vbOKCancel + vbInformation, "test title")
End Sub

2.はい、いいえボタンを表示

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Sub funcA()
Dim res As Integer
res = MsgBox("hello", vbYesNo + vbInformation)
Debug.Print res
End Sub
Sub funcA() Dim res As Integer res = MsgBox("hello", vbYesNo + vbInformation) Debug.Print res End Sub
Sub funcA()
    Dim res As Integer
    res = MsgBox("hello", vbYesNo + vbInformation)
    Debug.Print res 
End Sub

3.はい、いいえ、キャンセルボタンを表示

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

 

VBScript

Posted by arkgame