Visual Studio 2010 - 消息框弹出两次,为什么以及如何解决?

Visual Studio 2010 - Message Box popping up twice, why and how to fix?

我正在编写一个小应用程序,允许用户 return 并根据图表编号、订单号或产品 ID 的搜索更新三种类型的标签。设计的工作原理是有一个输入框,您可以在其中输入图表 number/order number/product id 并通过选择与上述三个输入选项相对应的三个单选按钮之一来指定。输入框右边有三个框,return是每类标签的标签ID,点击更新按钮可以直接编辑更新这些框的内容。问题是 return 消息在更新后弹出两次,这很麻烦,所以我想知道我应该在我的代码中更改哪里来解决这个问题?我将在下面粘贴完整代码,以防问题出现在我没有预料到的地方:

Imports MySql.Data.MySqlClient

Public Class Form1

    Dim dbconn As New MySqlConnection
    Dim sql As String
    Dim mycommand As New MySqlCommand
    Dim mydata As MySqlDataReader

    Public Sub myConnection()

        dbconn = New MySqlConnection("Server=###;Database=###;Uid=###;Pwd=###;")
        Try
            dbconn.Open()
        Catch ex As Exception
            MsgBox("Connection Error: " & ex.Message.ToString)
        End Try


    End Sub

    Private Sub chartNoSub()

        myConnection()

        sql = "SELECT pltlbl, cuslbl, boxlbl from formats as a join ordtab as b join chart as c where a.prodid=b.cusled and concat(b.ordno, b.orditm)=concat(c.ord01, c.oitm01) and c.chart='" & inputBox.Text & "'"

        mycommand.Connection = dbconn
        mycommand.CommandText = sql

        mydata = mycommand.ExecuteReader
        While (mydata.Read())
            pltLBL.Text = mydata.Item("pltlbl")
            cusLBL.Text = mydata.Item("cuslbl")
            boxLBL.Text = mydata.Item("boxlbl")
        End While

        mydata.Close()
        dbconn.Close()

    End Sub

    Private Sub ordNoSub()

        myConnection()

        sql = "SELECT pltlbl, cuslbl, boxlbl from formats as a join ordtab as b where a.prodid=b.cusled and concat(b.ordno, '-', b.orditm)='" & inputBox.Text & "'"

        mycommand.Connection = dbconn
        mycommand.CommandText = sql

        mydata = mycommand.ExecuteReader
        While (mydata.Read())
            pltLBL.Text = mydata.Item("pltlbl")
            cusLBL.Text = mydata.Item("cuslbl")
            boxLBL.Text = mydata.Item("boxlbl")
        End While

        mydata.Close()
        dbconn.Close()

    End Sub

    Private Sub prodIDsub()

        myConnection()

        sql = "select pltlbl, cuslbl, boxlbl from formats where prodid='" & inputBox.Text & "'"

        mycommand.Connection = dbconn
        mycommand.CommandText = sql

        mydata = mycommand.ExecuteReader
        While (mydata.Read())
            pltLBL.Text = mydata.Item("pltlbl")
            cusLBL.Text = mydata.Item("cuslbl")
            boxLBL.Text = mydata.Item("boxlbl")
        End While

        mydata.Close()
        dbconn.Close()

    End Sub

    Private Sub Input_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles inputBox.TextChanged

        pltLBL.Clear()
        cusLBL.Clear()
        boxLBL.Clear()

        If (inputBox.Text <> "" And prodID.Checked = False And ordNo.Checked = False And chart.Checked = False) Then MsgBox("Please select an option below before inputting.")

        If prodID.Checked = True Then
            prodIDsub()
        End If
        If ordNo.Checked = True Then
            ordNoSub()
        End If
        If chart.Checked = True Then
            chartNoSub()
        End If

    End Sub

    Private Sub update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updateLBL.Click, updateLBL.Click

        myConnection()

        sql = "update formats as a inner join ordtab as b on a.prodid = b.cusled inner join chart as c on b.ordno=c.ord01 and b.orditm=c.oitm01 set a.pltlbl = '" & pltLBL.Text & "', a.cuslbl = '" & cusLBL.Text & "', a.boxlbl = '" & boxLBL.Text & "' where a.prodid = '" & inputBox.Text & "' or concat(b.ordno, '-', b.orditm)='" & inputBox.Text & "' or c.chart='" & inputBox.Text & "'"

        mycommand.Connection = dbconn
        mycommand.CommandText = sql
        mycommand.CommandType = CommandType.Text
        Dim rows = mycommand.ExecuteNonQuery()

        If rows <> 0 Then
            MessageBox.Show("Update successful!")
        Else
            MessageBox.Show("Check input.")
        End If

        dbconn.Close()

    End Sub


    Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearLBL.Click

        prodID.Checked = False
        ordNo.Checked = False
        chart.Checked = False
        inputBox.Text() = ""

    End Sub
End Class

只是为了将此标记为已回答;

@GlorinOakenfoot 找到了这个解决方案,有点令人难以置信。

MsgBoxPrivate Sub update_Click 中被调用,但是 Handles 的事件在每次点击时发生两次,因此一切都递归。