Message Boxes

Written by Rod Wing.

Message Boxes are a means to quickly display information to the user.  Message boxes can also 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 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 want to continue?", _
                                      vbYesNo, "My Macro")
    If msgResult = VbMsgBoxResult.vbYes Then
            'User clicked Yes button
            'User clicked No button
    End If

CAD Training
' Display OK and Cancel buttons
    msgResult = MsgBox("Do you want to continue?", _
                                   vbOKCancel, "My Macro")
    If msgResult = VbMsgBoxResult.vbOK Then
            'User clicked OK button
            'User clicked Cancel button
    End If

CAD Training
' Display Abort, Retry, and Ignore buttons
    msgResult = MsgBox("Do you want to continue?", _
                           vbAbortRetryIgnore, "My Macro")
    Select Case msgResult
        Case VbMsgBoxResult.vbAbort
            'User clicked Abort button
        Case VbMsgBoxResult.vbIgnore
            'User clicked Ignore button
        Case VbMsgBoxResult.vbRetry
            'User clicked Retry button
    End Select


CAD Training



Rod Wing

Rod Wing

Rod joined EnvisionCAD in March 2007 and has nearly three decades of experience working in the CADD industry. He led the IT evaluations of Bentley InRoads and AutoDesk Civil 3D at Wisconsin DOT in their overall CAiCE replacement evaluation. He also led the MicroStation V7 to V8 upgrade effort at Wisconsin DOT which included updating not only the CADD standards to accommodate the changes in the file format but also updating legacy MDL and macros to work in the new environment. Rod received a Bachelor of Science degree from the University of Wisconsin in Cartography and a Master of Science in Geographic and Cartographic Sciences from George Mason University. Rod has extensive experience in CADD as well as the areas of GIS, cartography, plotting, scanning, raster editing/manipulation, publishing, and file/data translations. In all of these areas, he has produced custom tools and developed workflows to enhance productivity between diverse sets of applications. He instructs MicroStation classes ranging from fundamentals to advanced applications.


Leave a Reply

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