VBA Tip: Message Box Buttons

Written by Rod Wing.

 

Message Boxes are most often used as a means to quickly display information to the user. Message boxes can also be used to get basic Yes/No or Boolean type user input. Using Message boxes to get this kind of input can eliminate the need to develop custom UserForms to gather that information.

The MsgBox function returns a VbMsgBoxResult value which is an enumerated list with each item corresponding the button on the message box dialog selected by the user. The following code snippets illustrate the working with the MsgBox function to collect user input.

Dim msgResult As VbMsgBoxResult
' Display Yes and No buttons
msgResult = MsgBox("Do you ant to continue?", _
vbYesNo, "my Macro")
If msgResult = VbMsgBoxResult.vbYes Then
'User clicked Yes button
Else
'User clicked No button
End If

1

 

Last Month’s Tips:


Before and After Dimension Audit     7-1-2014 3-47-02 PM   notes 2     7-1-2014 3-52-47 PM

MicroStation: Dimension             InRoads: Working w/                   AutoCAD Civil 3D 2014:                   VBA: Input Boxes
     Audit Utility                            New Open Roads …                          How to Create New Parts…              
 
 
 
Don’t want to miss out on other great information? Subscribe to this blog or our monthly eNewsletter now!
Learn More ◊ Contact us today ◊ Newsletter ◊
EnvisionCAD Group EnvisionCAD YouTube Channel   

 

EnvisionCAD

Since 1996, EnvisionCAD has been a nationally recognized leader in the configuration, customization, implementation, training & support for CAD software solutions. Our individualized approach has benefited private engineering firms and government agencies alike. Basic or advanced, we can help you get the most from your CAD technology.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *