MsgBox Examples


Example 1 - vbInformation

Call MsgBox("MsgBox Prompt", _ 
            VBA.vbMsgBoxStyle.vbInformation + VBA.vbMsgBoxStyle.vbYesNo, _
            "MsgBox Title")

 


Example 2

Dim iResult As VBA.vbMsgBoxResult 
iResult = MsgBox ("MsgBox Prompt")

 


Example 3 - vbExclamation

Call MsgBox("MsgBox Prompt", _ 
             VBA.vbMsgBoxStyle.vbAbortRetryIgnore + VBA.vbMsgBoxStyle.vbExclamation + VBA.vbMsgBoxStyle.vbMsgBoxRight)

 


Example 4 - vbQuestion

This time the default button has been changed.

Dim lResult As VBA.vbMsgBoxResult 
lResult = MsgBox("MsgBox Prompt ?", _
             VBA.vbMsgBoxStyle.vbQuestion + VBA.vbMsgBoxStyle.vbYesNo + VBA.vbMsgBoxStyle.vbDefaultButton2)

 


Example 5 - vbCritical

Call MsgBox("MsgBox Prompt", _ 
             VBA.vbMsgBoxStyle.vbCritical + VBA.vbMsgBoxStyle.vbYesNoCancel + VBA.vbMsgBoxStyle.vbDefaultButton3 + VBA.vbMsgBoxStyle.vbMsgBoxHelpButton)

 

If no help file has been given then the Help button does not do anything.


Example 6

Call MsgBox("Press the Help button for more help", _ 
            VBA.VbMsgBoxStyle.vbCritical + VBA.VbMsgBoxStyle.vbYesNoCancel + VBA.VbMsgBoxStyle.vbMsgBoxHelpButton, , _
            "C:\temp\Help.chm", 1)

 

© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

PrevNext