Platform :

Popular Solution Go   Back

VB.NET - Effective Read Barcode with Scanned Image for vb.net

Step 1: Download Image Viewer CP Gold ActiveX setup disk and installed it.

Step 2: Create Visual Basic Windows Application project.

Step 3: Import  Image Viewer CP Gold ActiveX and add button on form.

Step 4: Add following code in buttons click event.

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ibarcodeCount As Integer
        Dim str1 As String
        Dim i As Integer
        Dim strTmp As String

        AxImageViewer1.FileName = "c:\testbarcode.bmp"
        AxImageViewer1.ConvertTo1bpp()
        ibarcodeCount = AxImageViewer1.BarCodeReadFullPage
        If ibarcodeCount < 1 Then
            MessageBox.Show("No barcode found ")
            Exit Sub
        End If

        str1 = "Total "   Str(ibarcodeCount) "BarCode Detected " Chr(13) Chr(10)

        For i = 0 To ibarcodeCount - 1
            strTmp = Me.AxImageViewer1.BarCodeGetType(i) " score:"     Str(Me.AxImageViewer1.BarCodeGetScore(i)) " value:" Me.AxImageViewer1.BarCodeGetValue(i)
            str1 = str1 Chr(13) Chr(10)  strTmp
        Next
        MessageBox.Show(str1)
    End Sub

Normally change to black white color of scanned image, it will improved the barcode reader to detect the barcode. Finally the barcode reader same cannot detect the barcode, you may try call BarCodeReadByZone method and selected specific area for scanning barcode.

e.g.

ibarcodeCount = AxImageViewer1.BarCodeReadByZone(314, 102, 224, 72)

Download this sample code