.NET Barcode Reader SDK > Read Barcode in VB.NET > VB.NET Barcodes Reader Component for Code 128, also read Code 39 Barcode in VB.NET

Code 128 VB.NET Barcode Reading Library


How to Read & Scan Code 128 Barcode Images in VB.NET Applications
  • A time-tested VB.NET Code 128 barcode reader, compatible with .NET 2.0 and above
  • Wholly written in managed C# and work perfectly with .NET development tools, like VS
  • Read & scan Code 128 from common image formats like gif, bmp, tiff, png and jpeg
  • Scan & decode Code 128 barcode in ASP.NET Web Applications & Console Applications
  • Besides Visual Basic, you can also scan, read Code 128 barcode in C# using BarcodeLib C# Barcode Reader tutorials.
  • Provide Windows Application Distribution License and Servers License for .NET developers
  • Offer prompt services and one-year free software update for our customers
This document describes the integration of Code 128 barcode reading functionality into Visual Basic .NET applications using BarcodeLib.

VB.NET Code 128 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


Scanning and reading Code 128 barcodes from images is a core function of the BarcodeLib .NET Barcode Scanner SDK control. It is compatible with Microsoft Visual Studio .NET Framework 2.0 and later versions. The BarcodeLib VB.NET barcode scanner is a robust and mature .NET barcode recognition component for VB.NET projects. One can easily scan and decode linear and 2D barcodes from image documents in VB.NET class, console application, ASP.NET web projects, and VB.NET Windows software (including WinForms and WPF).


How to Scan Code 128 Barcode in VB.NET?

Here we will use VB.NET Barcode Reader library to read an image containing a CODE128 barcode. It improves recognition accuracy by specifying optimization parameters, then iterates through all detected barcodes and extracts their decoded text messages.
  1. Create an OptimizeSetting instance configured specifically for CODE128 barcode decoding.
  2. Use method BarcodeReader.ReadBarcode() to read all barcodes from the specified image file using the optimization settings.
  3. Iterate through each detected barcode in the result array. Retrieve the decoded text message from the current barcode
Dim options As New OptimizeSetting(BarcodeReader.CODE128)
Dim barcodes As BarCode() = BarcodeReader.ReadBarcode("code128-barcode.png", options)
For Each barcode As BarCode In barcodes
    Dim barcodeText As String = barcode.GetMessage()
Next



Read colored, rotated Code 128 barcodes in VB.NET

BarcodeLib VB.NET Barcode Scanner sdk supports automatically scan and read all kinds of Code 128 barcodes, including colored Code 128, rotated barcodes in Visual Basic program.



Scan Code 128 with other barcode formats

If an image contains multiple barcodes with different symbologies, all of them can be scanned in one operation. The BarcodeLib VB.NET Barcode Reader library supports combined barcode type detection. Each barcode type can be identified using the returned metadata.
  • Create a OptimizeSetting with multiple barcode types specified.
  • Call method BarcodeReader.ReadBarcode() to get the scanned barcode objects.
  • Iterate through the BarCode array, use the GetTypeName() method to distinguish between different barcode formats.
  • Call GetMessage() to retrieve the decoded text for each valid barcode.
Dim options As New OptimizeSetting(New Integer() {
    BarcodeReader.DATAMATRIX, BarcodeReader.CODE128,
    BarcodeReader.CODE39, BarcodeReader.EAN13})
Dim barcodes As BarCode() = BarcodeReader.ReadBarcode("code128-barcodes.png", options)
For Each barcode As BarCode In barcodes
    Dim barcodeType As String = barcode.GetTypeName()
    Dim barcodeText As String = barcode.GetMessage()
Next



How to Retrieve Scanned Code 128 Barcode Properties in VB.NET

This section explains how to retrieve complete information from scanned Code 128 barcodes using the BarcodeLib VB.NET Barcode Reader library. The library can extract comprehensive metadata from scanned Code 128 barcodes. All details are accessible through the barcode result object for desktop application processing (WinForms/WPF).
  • Code 128 text message: The decoded raw data string from the barcode.
  • Verified barcode format: The confirmed and validated symbology type.
  • Code 128 position: The location and bounding coordinates of the barcode in the source image.
  • Code 128 start & encoding code set: The encoding mode used to generate the barcode.
  • Code 128 checksum codeword value: The validation check digit used for data integrity verification.


Read Code 128 Barcode Information

Key Code 128 barcode data can be accessed and validated through the returned BarCode object. Below are the most commonly used members for barcode processing.
  • Barcode Type: Use method GetTypeName() to validate that the detected barcode is Code 128. This is critical when scanning images with multiple barcode formats.
  • GetMessage(): Returns the raw decoded text string of the Code 128 barcode.
  • GetMessageInASCII(): Returns the processed ASCII text string of the Code 128 barcode. All non-printable ASCII characters are replaced with defined label characters.
  • IsGS1Compitable: Indicate whether the Code 128 is encoding GS1 data message. The barcode is also known as GS1-128.
  • Corners: Geometric information of the scanned Code 128 barcode. Gets the 4 vertex pixel coordinates that define the barcode bounding box in the image.
The following VB.NET code demonstrates how to implement Code 128 scanning and data extraction in a VB.NET application.
  • Iterate through the scanned BarCode objects.
  • Read and output the barcode type, raw text, formatted ASCII text, barcode location.
Dim options As New OptimizeSetting(BarcodeReader.CODE128)
Dim datas As BarCode() = BarcodeReader.ReadBarcode("code128-barcodes-sample.png", options)
For Each aBarcode As BarCode In datas
    Dim barcodeTypeName As String = aBarcode.GetTypeName()
    Dim data As String = aBarcode.GetMessage()
    Dim dataAscii As String = aBarcode.GetMessageInASCII()
    Dim isGs1Code128 As Boolean = aBarcode.IsGS1Compitable
    Dim barcodePosition As PointF() = aBarcode.Corners
Next


Code 128 Position, Rotation, Checksum, and Encoding Mode

After obtaining the BarCode object, the getBarcodeExtraInfos() method can be called. This method returns a Code128Info object for advanced decoding information.
  • getFirstSet(): Gets the initial encoding code set used by the Code 128 barcode (A, B, or C).
  • hasMultiSets(): Returns True if multiple code sets are used in a single Code 128 barcode.
  • getChecksum(): Gets the Code 128 checksum codeword value (valid range: 0 to 102) for data validation.
Dim options As New OptimizeSetting(BarcodeReader.CODE128)
Dim datas As BarCode() = BarcodeReader.ReadBarcode("code128-barcodes-sample.png", options)
For Each aBarcode As BarCode In datas
    Dim barcodeInfo As Code128Info = DirectCast(aBarcode.getBarcodeExtraInfos(), Code128Info)
    Dim startSet As Code128Set = barcodeInfo.getFirstSet()
    Dim isMutlipleSets As Boolean = barcodeInfo.hasMultiSets()
    Dim checksumCodeword As Integer = barcodeInfo.getChecksum()
Next


How to Read Code 128 ASCII Text in VB.NET

Code 128 supports encoding of all 128 standard ASCII characters.
  • 95 characters are printable, including digits (0-9), uppercase letters (A-Z), lowercase letters (a-z), and special symbols.
  • The other 33 characters are non-printable control characters.
A common example is the carriage return control character, represented as [CR]. Its ASCII value is 13. A sample barcode might contain encoded text such as Code[CR]128.

The BarcodeLib VB.NET Barcode Reader library provides the GetMessageInASCII() method. This method automatically replaces non-printable control characters with visible text labels.

Dim options As New OptimizeSetting(BarcodeReader.CODE128)
Dim datas As BarCode() = BarcodeReader.ReadBarcode("code128-barcode-sample.png", options)
For Each aBarcode As BarCode In datas
    Dim dataAscii As String = aBarcode.GetMessageInASCII()
Next



Verify Scanned Code 128 Barcode Data Using Check Character in VB.NET

Code 128 uses one mandatory check character for validity verification.
  • This character is automatically calculated and appended during barcode generation.
  • It is not displayed in the human-readable text label.
  • It is not included in the final decoded output from barcode scanners or software.
The BarcodeLib VB.NET Barcode Reader library provides built-in check character validation. It uses the scanned check character to verify data integrity automatically. Only valid barcode data is returned to the application.


Summary

The library offers comprehensive support for in memory scanning, multi format detection, property extraction, ASCII text handling, and automatic checksum verification. For WinForms and WPF applications, the same API patterns apply, enabling consistent integration across desktop and web environments. For other barcode symbologies such as Code 39, QR Code, or Data Matrix, refer to the respective documentation sections.