Public Enum MessageBoxButtons As Integer OK = 0 OkCancel = 1 AbortRetryIgnore = 2 YesNoCancel = 3 YesNo = 4 RetryCancel = 5 End Enum Public Enum DialogResult As Integer None = 0 OK = 1 Cancel = 2 Abort = 3 Retry = 4 Ignore = 5 Yes = 6 No = 7 End Enum Public Class EnhancedMessageBox Private m_sMessage As String = "" Private m_sTitle As String = "" Private m_xButtons As MessageBoxButtons = MessageBoxButtons.OK ''' ''' Create the message box that you want to display to the user. ''' ''' The message that you want to appear to the user. ''' The title of the message you are displaying to the user (leave blank if no title is desired). ''' The buttons that are to be displayed on the message box (uses the MessageBoxButtons enum to define which buttons appear). Public Sub New(ByVal sMessage As String, ByVal sTitle As String, ByVal xButtons As MessageBoxButtons) m_sMessage = sMessage m_sTitle = sTitle m_xButtons = xButtons End Sub ''' ''' Call this function to display the message box. ''' ''' This function returns a DialogResult enum of the button that the user clicked. Public Async Function ShowDialog() As Task(Of DialogResult) Dim xReturn As DialogResult = DialogResult.None Try Dim xMsgBox2 = New Windows.UI.Popups.MessageDialog(m_sMessage, m_sTitle) If m_xButtons = MessageBoxButtons.OK Then xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("OK")) ElseIf m_xButtons = MessageBoxButtons.OkCancel Then xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("OK")) xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Cancel")) ElseIf m_xButtons = MessageBoxButtons.AbortRetryIgnore Then xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Abort")) xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Retry")) xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Ignore")) ElseIf m_xButtons = MessageBoxButtons.YesNoCancel Then xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Yes")) xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("No")) xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Cancel")) ElseIf m_xButtons = MessageBoxButtons.YesNo Then xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Yes")) xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("No")) ElseIf m_xButtons = MessageBoxButtons.RetryCancel Then xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Retry")) xMsgBox2.Commands.Add(New Windows.UI.Popups.UICommand("Cancel")) End If Dim xResult As Windows.UI.Popups.UICommand = Await xMsgBox2.ShowAsync() Select Case xResult.Label Case "OK" xReturn = DialogResult.OK Case "Cancel" xReturn = DialogResult.Cancel Case "Abort" xReturn = DialogResult.Abort Case "Retry" xReturn = DialogResult.Retry Case "Ignore" xReturn = DialogResult.Ignore Case "Yes" xReturn = DialogResult.Yes Case "No" xReturn = DialogResult.No Case Else xReturn = DialogResult.None End Select Catch Exp As Exception ' End Try Return xReturn End Function End Class