.NET Barcode Reader & Scanner > Scan and Recognize Linear & 2D Barcode Images in VB.NET Applications

How to Scan Linear & 2D Barcode Image in VB.NET


Using VB.NET Barcode Scanner DLL to read barcodes in .NET, ASP.NET projects
  • Using high-quality barcode recognition features for VB.NET application barcode scanning & reading
  • Read linear and 2d (matrix) barcodes from ASP.NET web & .NET Windows Forms projects
  • Grant high speed barcode reading & scanning from image file formats, like Jpg, Gif, Png, Bmp, Tiff
  • Able to scan maximum one barcode per image, page in tiff or pdf document in VB.NET class library
  • Able to decode partial linear or matrix barcode image instead of the whole file in VB.NET class library
  • Directly use free VB.NET code to recognize Codabar, Code 39, Code 128, QR Code, Data Matrix, PDF-417, ect
  • Provide royalty-free .NET Barcode Reader Library Server & Windows Application Distribution License

VB.NET Barcode Reader Library

QR Code, Data Matrix, Code 128, GS1, EAN/UPC. Multi-thread reading in VB.NET Windows Forms, WPF application.

Download Now
NuGet Ready
.NET 5+
.NET Framework 4.x, 3.x, 2.x


VB.NET Barcode Reader DLL for .NET Introduction

BarcodeLib.com VB.NET Barcode Reader Library is a mature .NET barcode recognition control that enable users to read & decode linear and 2d barcode images. It can be used in:
  • ASP.NET Website Projects
  • .NET Windows Forms Projects
  • .NET WPF Desktop Application
  • .NET, C#, VB.NET Class Library
  • .NET Console Projects
Please note that, the first character of barcode data scanned by the trial package will be a random character.


How to read, scan barcodes in VB.NET?

The VB.NET source code below configures the vb.net barcode reader to scan Code 128 barcode type, loads an image file, and decodes all barcodes from it. It then iterates through each detected Code 128 barcode to retrieve its text message.
  1. Initialize OptimizeSetting specifically for Code 128 barcode decoding.
  2. Read all Code 128 barcodes found in the specified image file, applying the optimization settings.
  3. Loop through each decoded Code 128 barcode in the array. Use method GetMessage to extract the decoded text string from the each Code 128 barcode.
Dim options As New OptimizeSetting(BarcodeReader.CODE128)
Dim barcodes As BarCode() = BarcodeReader.ReadBarcode("barcode-sample.png", options)
For Each barcode As BarCode In barcodes
    Dim barcodeText As String = barcode.GetMessage()
Next



Scan multiple barcode formats at one time

The following Visual Basic code configures the barcode reader SDK to recognize both CODE39 and CODE128 barcode types simultaneously, processes the specified image file, and extracts the type and decoded text from each detected barcode.
  1. Create an OptimizeSetting instance that supports multiple barcode symbologies (Code 39 and Code 128).
  2. Call method BarcodeReader.ReadBarcode() to read all barcodes from the specified image file using the multi-symbology settings.
  3. Iterate through each detected barcode in the result BarCode object array. Retrieve the barcode type name and text string message.
Dim options As New OptimizeSetting(New Integer() {
    BarcodeReader.CODE39, BarcodeReader.CODE128})
Dim barcodes As BarCode() = BarcodeReader.ReadBarcode("barcode-formats-sample.png", options)
For Each barcode As BarCode In barcodes
    Dim barcodeType As String = barcode.GetTypeName()
    Dim barcodeText As String = barcode.GetMessage()
Next



Read colored, rotated, no text label barcodes in VB

BarcodeLib VB.NET Barcode Reader SDK supports automatically scanning all kinds of barcode, including colored barcode, rotated barcode, and barcode without text label printed.



How to improve barcode reading performance in VB.NET?

Quick to scan a single barcode

When processing a large image file. For instance, one that is 8MB in size, and that image contains only a single barcode, you can boost the decoding speed by using the following setting.

If the MaxOneBarcodePerPage option is enabled, the barcode reader library will stop scanning the remaining parts of the image immediately after it finds the first valid barcode.

Dim setting As New OptimizeSetting(BarcodeReader.CODE128)
setting.setMaxOneBarcodePerPage(True)


Scan image regions of interest in VB

Besides scanning the whole image, the barcode scanner library also provides the ability to scan specific regions, which helps boost reading speed.

The VB.NET source code below illustrates how to scan only the top 20% and bottom 20% of an image during barcode detection. This approach significantly cuts down on scanning time, CPU usage, and memory footprint.

To set up a scanning region, you simply need to specify the top‑left and bottom‑right anchor points. Each coordinate is given as a percentage of the image's total width and height. For example, (0%, 0%) denotes the top‑left corner, while (100%, 100%) denotes the bottom‑right corner of the entire image.

Dim setting As New OptimizeSetting(BarcodeReader.CODE128)

Dim top20 As New ScanArea(New PointF(0.0F, 0.0F), New PointF(100.0F, 20.0F))
Dim bottom20 As New ScanArea(New PointF(0.0F, 80.0F), New PointF(100.0F, 100.0F))
Dim areas As New List(Of ScanArea)()
areas.Add(top20)
areas.Add(bottom20)

setting.setAreas(areas)
Dim datas As BarCode() = BarcodeReader.ReadBarcode("barcode-sample.png", setting)
For Each aBarcode As BarCode In datas
    Dim data As String = aBarcode.GetMessage()
Next


Scan barcode image with specified directions

The VB.NET barcode component enables you to restrict scanning to specific directional axes. This option is controlled through the OptimizeSetting class via the setReadDirectionOrder() method.

You may specify a single direction or a combination of directions for scanning the image.

Dim setting As New OptimizeSetting(BarcodeReader.EAN13)
setting.setReadDirectionOrder(New Integer() {
    BarcodeReader.DIRECTION_LEFT_TO_RIGHT,
    BarcodeReader.DIRECTION_TOP_TO_BOTTOM
})


Scan image with sampling step

When the VB.NET barcode reading library handles a raster image, it processes the pixel data sequentially, row by row. The scanning resolution can be fine‑tuned through the ReadOncePerRowsCount property available in the OptimizeSetting class.

Dim setting As New OptimizeSetting(BarcodeReader.DATAMATRIX)
setting.setReadOncePerRowsCount(5)


Apply image zooming

In certain cases, enlarging a barcode image can significantly improve the read rate, as it supplies the decoding engine with a richer, more defined image. Turning an otherwise blurry or indistinct barcode into decipherable data.

The Visual Basic code below explains how to apply image zooming using BarcodeLib VB.NET Barcode Scanner library.

Dim setting As New OptimizeSetting(BarcodeReader.UPCA)
setting.setResizeRatio(2)


Read, decode barcode text data in VB.NET

Read, decode ASCII characters

ASCII table includes 128 characters. 95 printable characters and 33 control characters (non-printing chars). The following barcode types support ASCII characters encoding and decoding in VB.NET
  • Code 128
  • Code 39 (full ASCII mode)
  • QR Code
  • Data Matrix
  • PDF417
This VB.NET code shows the barcode reader to recognize a wide range of symbologies (CODE39 Extended, CODE128, QR Code, Data Matrix, and PDF417) in a single image file. It then decodes all detected barcodes and uses method GetMessageInASCII to retrieve their ASCII‑encoded message content.

Dim options As New OptimizeSetting(
    New Integer() {
    BarcodeReader.CODE39EX,
    BarcodeReader.CODE128,
    BarcodeReader.QRCODE,
    BarcodeReader.DATAMATRIX,
    BarcodeReader.PDF417
    }
)
Dim datas As BarCode() = BarcodeReader.ReadBarcode("barcode-ascii-sample.png", options)
For Each aBarcode As BarCode In datas
    Dim dataAscii As String = aBarcode.GetMessageInASCII()
Next



Read, decode Unicode text string

All 2d barcodes (QR Code, Data Matrix, PDF-417) supports Unicode text encoding. Using barcode reader library, you use GetMessage() to read the decoded Unicode text from 2d barcodes automatically.

Dim options As New OptimizeSetting(
    New Integer() {
    BarcodeReader.QRCODE,
    BarcodeReader.DATAMATRIX,
    BarcodeReader.PDF417
    }
)
Dim datas As BarCode() = BarcodeReader.ReadBarcode("2d-barcode-unicode-text.png", options)
For Each aBarcode As BarCode In datas
    Dim dataUnicode As String = aBarcode.GetMessage()
Next



Read, decode GS1 text message

The barcode symbologies support not only ISO standard, but also GS1 specification.
  • Code 128 (GS1-128)
  • QR Code (GS1 QR Code)
  • Data Matrix (GS1 Data Matrix)
To read GS1 text message from above barcode symbologies, you need apply The Visual Basic source code below shows the vb.net barcode reader to recognize QR Code, Data Matrix, and CODE128 symbologies, and enables GS1‑compliant decoding. It processes an image file containing GS1 barcodes, iterates through all detected barcodes, and extracts the full GS1 message (including Application Identifiers) only for those that are GS1‑compatible.
  • Create an OptimizeSetting instance that supports Code 128, QR Code and Data Matrix barcode symbologies.
  • Enable GS1 barcode reading mode. The barcode library will scan and decode GS1-128, GS1 QR Code and GS1 Data Matrix barcodes only.
  • Iterate through each detected barcode in the result array.
  • Use property IsGS1Compitable to check whether the current barcode is GS1 compatible.
  • Use method GetMessage to print the GS1 text message.
Dim options As New OptimizeSetting(
    New Integer() {
    BarcodeReader.QRCODE,
    BarcodeReader.DATAMATRIX,
    BarcodeReader.CODE128
    }
)
options.setReadGS1Barcode(True)

Dim datas As BarCode() = BarcodeReader.ReadBarcode("gs1-barcode-sample.png", options)
For Each aBarcode As BarCode In datas
    If (aBarcode.IsGS1Compitable) Then
        Dim dataGS1Text As String = aBarcode.GetMessage()
    End If
Next



VB.NET Linear & 2D Barcodes Reading & Decoding

Please click each barcode to see its barcode Visual Basic .NET recognition tutorial:
1D Barcodes in VB.NET:
2D Barcodes in VB.NET:
Able to Scan Linear Barcode Types: Codabar, Code 39, Code 128, Interleaved 2 of 5, EAN 8, EAN 13, UPC-A, UPC-E.

Able to Scan Matrix Barcode Types: Data Matrix, PDF 417, QR Code.
For VB.NET barcode generating guide, please refer to:












.NET Barcode Scanner, ASP.NET Barcode Scanner, C#.NET Barcode Scanner, VB.NET Barcode Scanner, QR Code .NET Scanner, QR Code ASP.NET Scanner, QR Code C# Scanner, QR Code VB.NET Scanner, Data Matrix .NET Scanner, Code 128 .NET Scanner, Code 39 .NET Scanner. .NET Barcoding Generator Library, Java Barcoding Generator Library.