Matt Matt - 1 year ago 103 Question

Combine two MsgBoxStyles in one with VB.NET

I'm trying to create a

that has both the
style and the
button style. What I've tried so far is this:

Private Sub DoSomething()
Dim Answer as MsgBoxResult
Answer = MsgBox("Error", MsgBoxStyle.RetryCancel & MsgBoxStyle.Critical, _
"Some sort of error.")
If Answer = MsgBoxResult.Retry Then
'REM: Try code again
Elseif Answer = MsgBoxResult.Cancel Then
Exit Sub
End If
End Sub

This is what the buttons currently look like:

Should be Retry/Cancel

There is no
icon on the message box.

How can I do this?


Use MessageBox instead of MsgBox. Try this:

    Dim _result As DialogResult = MessageBox.Show("Do you want to retry", "Confirm Retry", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
    If _result = Windows.Forms.DialogResult.Retry Then
        ' try again code

    End If

MessageBox Sample