MsgBox不会停止代码

时间:2014-08-11 11:57:37

标签: vb.net msgbox

我有一个onChange TextBox事件。当textlength为22时,应显示msgbox 并应建立数据库连接。

不幸的是,msgbox没有出现或出现并且消失的速度非常快。

不应该这样。我也试过使用ApplicationModal,但这并没有改变任何东西。

示例代码:

Private Sub txt_Auftrag_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_Auftrag.TextChanged

    If Len(txt_Auftrag.Text) = 22 Then 'txt_Auftrag.TextLength = 22 Then
        MsgBox("In der If", MsgBoxStyle.ApplicationModal Or MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
        var_Aufrag = Mid(txt_Auftrag.Text, 15, 8)


        '------------------------------------------SET dbConnection
        Dim myConn As SqlConnection
        Dim myCmdText As String

        Try
            Cursor.Current = Cursors.WaitCursor
            myConn = New SqlConnection("Data Source=127.0.0.1;Initial Catalog=db;User ID=dbadm;Password=pw")
            myConn.Open() 
            lbl_Auftrag_Value.Text = var_Aufrag
            Cursor.Current = Cursors.Default
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox("Verbindung zur Datenbank konnte nicht hergestellt werden. Kontaktieren Sie den Administrator. Fehlerbeschreibung: " & ex.Message)
            var_Aufrag = Nothing
            txt_Auftrag.Text = Nothing

            Exit Sub
        End Try

        MsgBox("ConnGood")

1 个答案:

答案 0 :(得分:0)

我想我明白了。我正在为MDT设备编程,并用它扫描条形码。当输入等于22的文本时,msgbox正在出现。当扫描条形码时,If语句在我的手指在扫描按钮上时开始并通过释放它来点击msgbox。无论如何非常奇怪:)

Thx和bye

相关问题