We are very familiar with messagebox class, this is widely used in any application .net framework provides various ways for using messagebox in application.
We have been using messagebox in very simple ways like
Messagebox.show("hello this is vb.net application")
But we can use messagebox with different –different styles such as messagebox with predefined icon,messagebox with multiple buttons like Yes,No,abort……
In this article we will discuss messagebox with multiple buttons in brief.
Suppose in our application there is one form with some textboxs and values of these textboxes filled on the basis of unique id from database now user can change some values of textbox(s), and want to close this form. you want to display a message 'Do you want to save data before closing this form' with Yes and No button. User can select yes or No button.


We can do that like this:
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If (MessageBox.Show("Do you want to save data before closing this form", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) = Windows.Forms.DialogResult.Yes Then
' Update query
Else
Me.Close()
End If
End Sub