20. Advanced MessageBox

In the second tutorial, we covered how to display a message box reading “Hello World”. In this tutorial, we cover how to create a more advanced message box by changing the icon and the buttons displayed. We also learn how to get input from the user by finding out what button they have clicked.

Code

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If MessageBox.Show("whatever", "whatever", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            MessageBox.Show("you clicked yes")
        Else
            MessageBox.Show("you clicked no")
        End If
    End Sub

End Class