mardi 5 mai 2015

Scan Qr Code add to DataGridView and Stop if Value is already there

Hello i am trying to Scan a Qr Code. then check if the code or value is in the DataGridView. if it is found i need a msgbox to let me know it is already scanned. if not proceed to input it to DataGrid and stop or some kind of delay so that there is time to change qr code.

the code i have will scan but i get loop of msgbox and have to cover camera to stop the "spam" msgboxes. i believe i have worded the code wrong any help you might give me?

This is what i need . Scan -- >Value in datagrid (If No then add to datagrid and Delay) (If Yes MsgBox "Already in system" Delay Start Over).

My code:

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

Aucun commentaire:

Enregistrer un commentaire