Visual Basic:当我单击按钮时消息框提示两次

时间:2014-08-14 13:39:11

标签: vb.net if-statement messagebox

我的留言框有问题。这是app的一部分,用于检查序列号是否已被使用。如果是,则显示错误消息,当单击YES程序继续并执行一些功能时,NO按钮结束子。它运作良好,但它会向我显示两次消息框,我真的不明白为什么,请帮助

If File.Exists(pathSN) Then
    Dim Findstring = IO.File.ReadAllText(pathSN)

    If Findstring.Contains(Lookfor) Then
        Dim msg = "Serial number has already been used"
        Dim title = "Error"
        Dim style = MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2 Or _
                    MsgBoxStyle.Critical
        Dim response = MsgBox(msg, style, title)
        MsgBox(msg, style, title)

        If response = MsgBoxResult.Yes Then
            wrlayout()
            openlayout()
            Exit Sub
        Else
            Exit Sub
        End If
    End If
End If

1 个答案:

答案 0 :(得分:2)

... Dim response = MsgBox(msg, style, title) MsgBox(msg, style, title) ...

您不需要第二次拨打MsgBox