Search code examples
vb.netwinformsmessagebox

Can you have two sets of buttons on a single messagebox? vb.net


Is this possible to do and have each set control separate code?

What I'm looking to achieve is ask two questions in a single messagebox which is easy to do but how would I give functionality to each button and prevent the messagebox from closing upon answering one of the questions?

This is question 1
  Yes    No

This is question 2
  Yes    No

Is there a way to prevent the messagebox from closing if you answer question 1 as yes and not close unless they answer the 2nd question?


Solution

  • You can't do this with MessageBox as-is. You'd have to create a custom dialog box.

    You could always check the result of messagebox1 and have it control the following logic for messagebox2 to display or not?

    Dim result = MsgBox("This is question 1")
    If result = MsgBoxResult.Ok Then
        'do something
    End If