none
MsgBox Question

    Question

  • I'm supposed to make a form (VisualBasic) where you can suggest something. I gave the option "go back to the menu" and with a MsgBox I need it to ask "You are sure?" (something like that). When I press the button of Ok it goes back to the menu, but when I press the button of Cancel (that is supposed to KEEP me in the same form) still closes and sends me back to the menu. How do I change that??

    Any suggestion?

    Tuesday, April 4, 2017 11:01 PM

All replies

  • Hi aasanroman

     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If MessageBox.Show("Are yo sure?",
                               "Message",
                               MessageBoxButtons.OKCancel,
                               MessageBoxIcon.Question,
                               MessageBoxDefaultButton.Button2
                               ) = Windows.Forms.DialogResult.OK Then
                Me.Close()
            Else
                Return
            End If
        End Sub
    Regards


    Si ayudé a resolver tu consulta, no olvides marcar como respuesta y/o votar como útil.

    Tuesday, April 4, 2017 11:07 PM
  • Hi aasanroman,

    Welcome to the MSDN forum.

    Refer to your description, your issue is about the development of VB. Since our forum is to discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor, I will help you move it to the appropriate forum: Visual Studio Languages Visual Basic for dedicated information, you will get a more professional support from there, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 5, 2017 6:27 AM
  • Hi aasanroman,

    It seems that Brayan De La Cruz's reply resolve your issue, if so, please mark it as answer, it will be beneficial to other communities who have the same issue.

    Thanks for your understanding.

    Best Regards,

    Cherry Bu



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 6, 2017 6:19 AM
    Moderator