Code snippets for VB.net
This arcticle shows some simple VB.net code snippets that reference the .net component or com object for the SDK in Visual Studio.
.NET Managed Class Library with Visual Studio 2003
‘Add a reference to SoftekBarcodeLib.dll
Dim barcode As SoftekBarcodeLib.BarcodeReader
barcode = New SoftekBarcodeLib.BarcodeReader
‘Set properties
barcode.ReadCode128 = True
‘Read barcodes
nBarCodes = barcode.ScanBarCode(Path)
‘Get results
For i = 1 To nBarCodes
strBarcode = barcode.GetBarString(i)
.NET Managed Class Library with Visual Studio 2005/2008
‘Add a reference to SoftekBarcodeLib2.dll
Dim barcode As SoftekBarcodeLib2.BarcodeReader
barcode = New SoftekBarcodeLib2.BarcodeReader
‘Set properties
barcode.ReadCode128 = True
‘Read barcodes
nBarCodes = barcode.ScanBarCode(Path)
‘Get results
For i = 1 To nBarCodes
strBarcode = barcode.GetBarString(i)
Standard Windows DLL
Dim hBarcode As System.IntPtr
hBarcode = mtCreateBarcodeInstance()
‘See the example project for the function definitions for the SoftekBarcode dll file.
‘Set properties
mtSetReadCode128(hBarcode, True)
‘Read barcodes
nBarCodes = mtScanBarCode(hBarcode, Path)
‘Get results
For i = 1 to nBarCodes
strBarcode = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(mtGetBarString(hBarcode, i)))
mtDestroyBarcodeInstance(hBarcode)
COM Object
‘Add a reference to SoftekATL.dll
Dim oBarcode As SoftekATL.CBarcode
oBarcode = New SoftekATL.CBarcode
‘Set properties
oBarcode.ReadCode128 = True
‘Read barcodes
oBarcode.ScanBarCode(Path.ToString)
nBarCodes = oBarcode.BarCodeCount
‘Get results
For i = 1 to nBarCodes
strBarcode = oBarcode.BarString(i)
Adding References to Visual Studio
To add a reference in Visual Studio, select “Add Reference” from the Project menu.
To add a reference for the managed class library, browse for the SoftekBarcodeLib.dll file for VS 2003 and SoftekBarcodeLib2.dll for VS 2005/2008 in your windows system folder.
To add a reference for the COM object, click on the COM tab and select SofteATL 1.0 Type Library from the list.