代码之家  ›  专栏  ›  技术社区  ›  lukas31

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

  •  -2
  • lukas31  · 技术社区  · 10 年前

    我的消息框有问题。这是检查序列号是否已被使用的应用程序的一部分。如果是,它会显示错误消息,当单击“是”程序继续并执行某些功能时,“否”按钮结束。它工作正常,但它会向我显示两次消息框,我真的不明白为什么,请帮助

    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 回复  |  直到 10 年前
        1
  •  2
  •   paul    10 年前

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

    您不需要第二次呼叫 MsgBox