使用VB.NET将两个MsgBoxStyles合二为一

Mat*_*att 4 vb.net styles button winforms

我正在尝试创建一个MsgBox()既有MsgBoxStyle.Critical样式又有MsgBoxStyle.RetryCancel按钮样式的东西.到目前为止我尝试过的是:

Private Sub DoSomething()
    Dim Answer as MsgBoxResult
        Answer = MsgBox("Error", MsgBoxStyle.RetryCancel & MsgBoxStyle.Critical, _
        "Some sort of error.")
    If Answer = MsgBoxResult.Retry Then
        'REM: Try code again
    Elseif Answer = MsgBoxResult.Cancel Then
        Exit Sub
    End If
End Sub
Run Code Online (Sandbox Code Playgroud)

这就是按钮目前的样子:

应该是重试/取消

Critical消息框中没有图标.

我怎样才能做到这一点?

GSe*_*erg 9

按位"合并"被称为Or.

MsgBoxStyle.RetryCancel Or MsgBoxStyle.Critical
Run Code Online (Sandbox Code Playgroud)

MsgBoxStyle.RetryCancel & MsgBoxStyle.Critical评估"5" + "16",评估,评估"516",哪个评估516,哪个神奇地等于MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton3,因此被解释为.

不要将字符串连接运算符&用于按位逻辑.