How about this
If My.Application.Question("Continue") Then
...
End If
Namespace My
Partial Friend Class MyApplication
''' <summary>
''' Ask question with NO as the default button
''' </summary>
''' <param name="QuestionText"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function Question(ByVal QuestionText As String) As Boolean
Return (Windows.Forms.MessageBox.Show(QuestionText,
My.Application.Info.Title, Windows.Forms.MessageBoxButtons.YesNo,
Windows.Forms.MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) =
MsgBoxResult.Yes)
End Function
''' <summary>
''' Ask question, NO is default button
''' </summary>
''' <param name="QuestionText"></param>
''' <param name="Title"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function Question(ByVal QuestionText As String, ByVal Title
As String) As Boolean
Return (Windows.Forms.MessageBox.Show(QuestionText, Title,
Windows.Forms.MessageBoxButtons.YesNo,
Windows.Forms.MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) =
MsgBoxResult.Yes)
End Function
''' <summary>
''' Ask question
''' </summary>
''' <param name="QuestionText">Question to ask</param>
''' <param name="Title">Text for dialog caption</param>
''' <param name="DefaultButton">Which button is the default</param>
''' <returns></returns>
''' <remarks></remarks>
Public Function Question(ByVal QuestionText As String, ByVal Title
As String, ByVal DefaultButton As MsgBoxResult) As Boolean
Dim db As Windows.Forms.MessageBoxDefaultButton
If DefaultButton = MsgBoxResult.No Then
db = Windows.Forms.MessageBoxDefaultButton.Button2
End If
Return (Windows.Forms.MessageBox.Show(QuestionText, Title,
Windows.Forms.MessageBoxButtons.YesNo,
Windows.Forms.MessageBoxIcon.Question, db) = MsgBoxResult.Yes)
End Function
End Class
End Namespace