VB.Net
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:
- 100% Managed .NET Component
- VB.Net Wrapper Class
100% .NET Managed Component
It's simple to read barcodes with 100% Managed .NET Component:
Either
Download the example VB.Net project that shows you how to use the component.
Or
Open or Create a VB.Net Project.
From the project menu select "Add Reference" and browse for the SoftekBarcodeLib.dll file in the windows system folder.
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:
Either
Download an example VB.Net project that shows you how to use the SoftekBarcode Class.
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).
Or
Open or Create a VB.Net Project.
From the project menu select "Add Existing Item" (Shift Alt A) and browse for the SoftekBarcode.vb class, which will usually be found in C:\Program Files\Softek Software\Barcode\DLL.
See the code below for a simple example of how to use the SoftekBarcode class.
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 |