MessageBox with YesNoCancel - No & Cancel triggers same event

前端 未结 9 1116
误落风尘
误落风尘 2020-12-04 21:23

I have a message box with the YesNoCancel buttons...

  • Pressing Yes will do some action and close the application - works fine
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 21:51

    Closing conformation alert:

    Private Sub cmd_exit_click()
    
        ' By clicking on the button the MsgBox will appear
        If MsgBox("Are you sure want to exit now?", MsgBoxStyle.YesNo, "closing warning") = MsgBoxResult.Yes Then ' If you select yes in the MsgBox then it will close the window
                   Me.Close() ' Close the window
        Else
            ' Will not close the application
        End If
    End Sub
    

提交回复
热议问题