how can i exit from the form after clicking the "yes" button of a messageBox??

are you really don't know how to do it?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim msg As MsgBoxResult
        If MsgBox("Do you really want to exit ?", MsgBoxStyle.YesNo, "Exit") = msg.Yes Then
        End If
    End Sub

Its depends on your form, if your form is startup form of project you can use hide method otherwise you can use close method.
If your form is startup form and you use close method then you project is closed.

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            DialogResult = MessageBox.Show("R U Sure To Close the Form", "Closing Form", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (DialogResult == DialogResult.OK)
                Form1 f = new Form1();
                e.Cancel = true;

Use this for Message Box based Closing of a form.

c# code in forum :'(
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        DialogResult = MsgBox("R U Sure, to Close the Form", MsgBoxStyle.OkCancel, "Confirmation")
        If (DialogResult = Windows.Forms.DialogResult.OK) Then
            Dim f As New Form1
            e.Cancel = True
        End If
    End Sub

By mistake i have given the C#.Net code, this code is Equivalent VB Code for MsgBox Closing of Form.

This article has been dead for over six months. Start a new discussion instead.