Barcode Recognition with VB.Net
Barcode Recognition Software
The Softek Barcode Toolkit is an application programmers toolkit which reads barcodes from image files and bitmaps - with a choice of 5 types of interface: DLL, OCX, COM , VB Wrapper Class and .NET .
There are 2 interfaces that can be used with VB.Net:
It's simple to read barcodes with 100% Managed .NET Component:
Or
See the code below for a simple example of how to use the SoftekBarcode class.
Declarations section:
Dim barcode As SoftekBarcodeLib.BarcodeReader
Dim nBarCode As Short
Dim strBarcode As String
Dim bm As Bitmap
In the New subroutine:
barcode = New SoftekBarcodeLib.BarcodeReader()
In the code where you want to read a barcode:
' Barcode might be in any direction
barcode.ScanDirection = 15
' Only look for EAN-8 barcodes
barcode.ReadCode128 = False
barcode.ReadCode39 = False
barcode.ReadCode25 = False
barcode.ReadEAN13 = False
barcode.ReadEAN8 = True
barcode.ReadUPCA = False
barcode.ReadUPCE = False
' Scan every line of the image
barcode.LineJump = 1
nBarCode = barcode.ScanBarCode("C:\Program Files\Softek Software\Softek Barcode Toolkit\pen.jpg")
' Or read the barcode from an image in a PictureBox
' bm = New Bitmap(Me.PictureBox1.Image)
' nBarCode = barcode.ScanBarCodeFromBitmap(bm.GetHbitmap())
If (nBarCode < 0) Then
MsgBox("Error reading barcode")
ElseIf (nBarCode = 0) Then
MsgBox("No barcode found on this image")
Else
strBarcode = barcode.GetBarString(1)
MsgBox(strBarcode)
End If
VB Wrapper Class
It's simple to read barcodes with VB.Net:
Hint: The SoftekBarcode Class uses "Get" and "Set" methods to access properties. For example, to get the value of the LineJump property call GetLineJump(), and to set the value call SetLineJump(newValue).
Declarations section:
Dim barcode As SoftekBarcode
Dim nBarCode As Short
Dim strBarcode As String
Dim bm As Bitmap
In the New sub routine:
barcode = New SoftekBarcode()
In the code where you want to read a barcode:
' Barcode might be in any direction
barcode.SetScanDirection(15)
' Only look for EAN-8
barcodes barcode.SetReadCode128(False)
barcode.SetReadCode39(False)
barcode.SetReadCode25(False)
barcode.SetReadEAN13(False)
barcode.SetReadEAN8(True)
barcode.SetReadUPCA(False)
barcode.SetReadUPCE(False)
'Scan every line of the image
barcode.SetLineJump(1)
nBarCode = barcode.ScanBarCode("C:\Program Files\Softek Software\Softek Barcode Toolkit\pen.jpg")
' Or read the barcode from an image in a PictureBox
' bm = New Bitmap(Me.PictureBox1.Image)
' nBarCode = barcode.ScanBarCodeFromBitmap(bm.GetHbitmap())
If (nBarCode < 0) Then
MsgBox("Error reading barcode")
ElseIf (nBarCode = 0) Then
MsgBox("No barcode found on this image")
Else
strBarcode = barcode.GetBarString(1)
MsgBox(strBarcode)
End If