Message Box with Retry and Cancel buttons in vb.net

 
Following example display a messagebox with Retry and Cancel buttons in vb.net.

 Private Sub ShowRetryCancelMessage()
        Dim resultDlg As Integer
        resultDlg = MessageBox.Show("Error in this process", "", _
                                    MessageBoxButtons.RetryCancel, _
                                    MessageBoxIcon.Error, _
                                    MessageBoxDefaultButton.Button2)
 
        If resultDlg = DialogResult.Retry Then
            ' Write code.....
        Else
            ' Write code.....
        End If
    End Sub