Let me take a few moments here before getting into the project code to discuss some issues that don't really fit into any particular chapter discussion, but that you might end up using a lot in your own applications.
Although I've used it on practically every page of this book so far, I have never formally introduced you to the
MsgBox method. Part of the
MsgBox is a carryover from the
MsgBox function in the original release of Visual Basic. It displays a simple message window, including a selection of response buttons and an optional icon. As a function, it returns a code indicating which button the user clicked to close the form, one of the
MsgBoxResult enumeration values. The syntax is:
Public Function MsgBox(ByVal Prompt As Object, _ Optional ByVal Buttons As MsgBoxStyle = MsgBoxStyle.OKOnly, _ Optional ByVal Title As Object = Nothing) As MsgBoxResult
Prompt parameter accepts a string for display in the main body of the dialog;
Buttons indicates which buttons, icons, and other settings to use when displaying the dialog; and
Title accepts a custom window title if you want something other than the application title to appear. The following statement displays the window in Figure 8-2:
Figure 8-2. Communicating an important message
Dim result As MsgBoxResult = MsgBox( _ "It's safe to click; the computer won't explode.", ...