0
您好,我正在嘗試掃描一個二維碼。然後檢查代碼或值是否在DataGridView中。如果發現我需要一個msgbox讓我知道它已經被掃描。如果不是繼續將其輸入到DataGrid並停止或某種延遲,以便有時間更改qr代碼。掃描二維碼添加到DataGridView和停止如果價值已經存在
我已經掃描的代碼,但我得到了msgbox的循環,並必須覆蓋相機停止「垃圾郵件」msgboxes。我相信我的代碼錯誤可能會給我任何幫助?
這就是我需要的。 掃描 - >數據網格中的值(如果否,則添加到數據網格和延遲)(如果是MsgBox「已在系統中」延遲重新開始)。
我的代碼:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If VideoSourcePlayer1.GetCurrentVideoFrame() IsNot Nothing Then
Dim img As New Bitmap(VideoSourcePlayer1.GetCurrentVideoFrame)
Dim results As String() = BarcodeReader.read(img, BarcodeReader.QRCODE)
img.Dispose()
If results IsNot Nothing AndAlso results.Count > 0 Then
If results(0).IndexOf("event") <> -1 Then
'Remove verification code and post to listbox
results(0) = results(0).Replace("event", "")
Dim code As String = results(0)
Try
If DataGridView2.Rows.Count >= 0 Then
For i As Integer = 0 To DataGridView2.Rows.Count - 1
Dim CellChange As String = DataGridView2.Rows(i).Cells("CODE").Value.ToString
If CellChange.Contains(results(0)) = True Then
Timer1.Stop()
MsgBox("Ticket already in system")
If MsgBoxResult.Ok Then
Timer1.Start()
End If
Else
Timer1.Stop()
DataGridView2.Rows.Add(code)
Timer1.Start()
End If
Next
End If
Catch ex As Exception
MessageBox.Show(e.ToString())
End Try
End If
End If
End If
End Sub