Title: Message Boxes
1Message Boxes
2Simple MessageBox
- Delivers a message to the user.
- Stops the procedure until the user clicks on OK
3 Private Sub simplemessageButton_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles simplemessageButton.Clic
k MessageBox.Show("This is the message.
It holds up the completion of the event handler
until the user clicks on OK.")
simpleLabel.Text "Done" End Sub
4Selection MessageBox
5 Private Sub decisionmessageButton_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles decisionmessageButton.Cl
ick ' Initializes variables to pass to
the MessageBox.Show method. Dim Message
As String "You did not enter a server name.
Cancel this operation?" Dim Caption As
String "No Server Name Specified"
'_________________________________________________
__ 'Note that the following specifies
Integers!!! '_____________________________
______________________ Dim Buttons As
Integer MessageBoxButtons. Dim
DefaultButton As Integer MessageBoxDefaultButton
.Button3 Dim BoxOptions As Integer
MessageBoxOptions.RightAlign Dim Result
As DialogResult
6 'Displays a MessageBox using the Question
icon and specifying the No button as the
default. Result MessageBox.Show(Me,
Message, Caption, Buttons, MessageBoxIcon.Question
, _ DefaultButton, BoxOptions)
'Remember that Me is this form class. The
message box 'will appear in front of
this form.
7 'Select Case gets the result of the
MessageBox display and takes action
'depending on the value of the result.
Select Case Result Case
DialogResult.Yes resultLabel.Text
"Yes" Case DialogResult.No
resultLabel.Text "No" Case
DialogResult.Cancel
resultLabel.Text "Cancel" End Select
End Sub