0% found this document useful (1 vote)
385 views2 pages

VB.NET MessageBox.Show Examples

The document discusses using the MessageBox.Show function in VB.NET to display message boxes. It shows how MessageBox.Show can be called directly without an instance reference. Depending on the number of arguments passed to MessageBox.Show, different types of message boxes can be displayed, such as single-argument, two-argument, three-argument, etc. up to seven arguments. The code sample demonstrates calling MessageBox.Show with varying numbers of arguments to display different message boxes and check the results.

Uploaded by

leth_alix
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
385 views2 pages

VB.NET MessageBox.Show Examples

The document discusses using the MessageBox.Show function in VB.NET to display message boxes. It shows how MessageBox.Show can be called directly without an instance reference. Depending on the number of arguments passed to MessageBox.Show, different types of message boxes can be displayed, such as single-argument, two-argument, three-argument, etc. up to seven arguments. The code sample demonstrates calling MessageBox.Show with varying numbers of arguments to display different message boxes and check the results.

Uploaded by

leth_alix
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Using MessageBox.

Show function

First here we look at an event handler in the [Link] language that will show the message boxes in the screenshot sequentially when
the program executes. The [Link] function is a Public Shared Function type in the [Link] language and it can be called
without an instance reference. You can invoke [Link] directly. The method receives different numbers of parameters, and
by specifying certain arguments and the right number of arguments, you can get the desired dialog box.

Public Class Form1


Private Sub Form1_Load(ByVal sender As [Link], _
ByVal e As [Link]) Handles [Link]
'
' First show a single-argument dialog box with [Link].
'
[Link]("Dot Net Perls is awesome.")
'
' Show a two-argument dialog box with this method.
'
[Link]("Dot Net Perls is awesome.", _
"Important Message")
'
' Use a three-argument dialog box with [Link].
' ... Also store the result value in a variable slot.
'
Dim result1 As DialogResult = [Link]("Is Dot Net Perls awesome?", _
"Important Question", _
[Link])
'
' Use four parameters with the method.
' ... Use the YesNoCancel enumerated constant and the Question icon.
'
Dim result2 As DialogResult = [Link]("Is Dot Net Perls awesome?", _
"Important Query", _
[Link], _
[Link])
'
' Use five arguments on the method.
' ... This asks a question and you can test the result using the variable.
'
Dim result3 As DialogResult = [Link]("Is Visual Basic awesome?", _
"The Question", _
[Link], _
[Link], _
MessageBoxDefaultButton.Button2)
'
' Use if-statement with dialog result.
'
If result1 = [Link] And _
result2 = [Link] And _
result3 = [Link] Then
[Link]("You answered yes, yes and no.") ' Another dialog.
End If
'
' Use [Link] overload that has seven arguments.
'
[Link]("Dot Net Perls is the best.", _
"Critical Warning", _
[Link], _
[Link], _
MessageBoxDefaultButton.Button1, _
[Link], _
True)
'
' Show a dialog box with a single button.
'
[Link]("Dot Net Perls is super.", _
"Important Note", _
[Link], _
[Link], _
MessageBoxDefaultButton.Button1)
End Sub
End Class

You might also like