VB.NET Code 128 Reader & Scanner SDK


How to scan, read Code 128 barcode images in Visual Basic .NET Windows application?

How to read, scan, decode Code 128 images in VB.NET class, ASP.NET Web & Windows applications

  • Scan Code 128 barcode in VB.NET class, Console applications
  • Read Code 128 barcode in VB.NET ASP.NET web projects
  • Read, decode Code 128 images in Visual Studio VB.NET Windows Forms applications
  • Easy and simple to integrate Code 128 reader component (single dll file) into your VB.NET project
  • Detailed tutorials on read barcode in asp.net c#, read barcode in c# windows application
  • Complete developed in C# 2005, for .net framework 2.0 and later version
  • Scanning, decoding Code 128 from multiple image formats, like BMP, GIF, JPEG, PNG, TIFF formats
  • Scanning, reading Code 128 from multi-page TIFF documents


How to read, scan Code 128 barcode image in VB.NET application

  1. Download .NET Code 128 Barcode Reader Library
  2. Install VB library to scan Code 128 barcode images in VB.NET apps
  3. Step by Step Tutorial












Scan, Read Code 128 barcodes from images is one of the barcode reading functions in .NET Barcode Scanner SDK control. It is compatible for Microsoft Visual Studio .NET framework 2.0 and later version. VB.NET barcode scanner is a robust and mature .net barcode recognition component for VB.NET projects. You can easily scan and decode linear, 2d barcodes from image documents in your VB.NET class, console application, ASP.NET web projects, and VB.NET Windows software.
To help .net developers easiy integrate barcode reader control into your .net projects, we provide detailed online tutorial for
VB.NET Barcode Reader component supports scanning and reading 20+ linear, 2d barcodes, including
You may also be interested in:


Quick to scan Code 128 barcodes in VB.NET WinForms, WPF application

Here we will show how to scan and recognize Code 128 (linear 1D barcode symbology) using the VB.NET Barcode Reader library.

You can implement Code 128 barcode scanning with a direct method call in VB.NET. The core scanning method accepts an image source and target barcode type as input parameters.

  1. Call the core decoding method BarcodeScanner.Scan().
  2. Pass the barcode image file path as the first parameter.
  3. Specify the barcode type as BarcodeType.Code128.
  4. The method returns a string array containing all decoded barcode data.

Dim datas As String() = BarcodeScanner.Scan(
    "code-128-barcode-image.gif", BarcodeType.Code128)



Scan Code 128 barcode image in memory

The BarcodeScanner.Scan() method supports not only image file paths but also Stream objects as input. This is ideal for in-memory image processing in desktop applications. You can load image bytes into a MemoryStream and perform scanning directly without physical files.

  1. Read the image file into a byte array.
  2. Convert the byte array to a MemoryStream object.
  3. Call BarcodeScanner.Scan() with the Stream and BarcodeType.Code128.
  4. Get the decoded barcode data as a string array.

' Read image file into a byte array
Dim dataBytes As Byte() = File.ReadAllBytes("code128-barcode.png")

' Create a MemoryStream from the byte array
Dim barcodeInStream As Stream = New MemoryStream(dataBytes)

' Scan Code 128 barcode from the Stream object
Dim datas As String() = BarcodeScanner.Scan(barcodeInStream, BarcodeType.Code128)


Scan Code 128 from multi-barcode formats

If your image contains multiple barcodes with different symbologies, you can scan all of them in one operation.

The VB.NET Barcode Reader library supports combined barcode type detection. You can identify each barcode type using the returned metadata.

  1. Call the BarcodeScanner.ScanInDetails() method for detailed barcode information.
  2. Combine multiple barcode types using the Or operator: BarcodeType.Code128 Or BarcodeType.Code39.
  3. Validate the returned result array.
  4. Iterate through the BarcodeDetail array.
  5. Use the Type property to distinguish between different barcode formats.
  6. Call GetMessage() to retrieve the decoded text for each valid barcode.

' Scan mixed barcodes: Code 128 and Code 39 in one operation
Dim datasInDetail As BarcodeDetail() = BarcodeScanner.ScanInDetails(
    "sample-barcodes.png", BarcodeType.Code128 Or BarcodeType.Code39)

' Check if valid scanning results are returned
If datasInDetail IsNot Nothing AndAlso datasInDetail.Length > 0 Then
    ' Iterate all detected barcode records
    For Each barcodeInfo As BarcodeDetail In datasInDetail
        ' Identify and process Code 128 barcode
        If barcodeInfo.Type = BarcodeType.Code128 Then
            Dim Code128Text As String = barcodeInfo.GetMessage()
        End If
    Next
End If




How to retrieve scanned Code 128 barcode properties in VB.NET?

Here we will learn how to retrieve complete information from scanned Code 128 (linear 1D barcode symbology) using the VB.NET Barcode Reader library.

The VB.NET Barcode Reader library can extract comprehensive metadata from scanned Code 128 barcodes. All details are accessible through the barcode result object for desktop application processing.
  • 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.




Extract Code 128 core information

You can access and validate key Code 128 barcode data through the returned BarcodeDetail object.

Below are the most commonly used members for barcode processing.

  1. Type
    Validates that the detected barcode is Code 128.
    This is critical when scanning images with multiple barcode formats.
  2. GetMessage()
    Returns the raw decoded text string of the Code 128 barcode.
  3. GetASCIITextMessage()
    Returns the processed ASCII text string of the Code 128 barcode.
    All non-printable ASCII characters are replaced with defined label characters.

The VB.NET codes below show how to implement Code 128 scanning and data extraction in VB.NET application.

  1. Call BarcodeScanner.ScanInDetails() to scan the barcode image.
  2. Set the target barcode type to BarcodeType.Code128.
  3. Check if valid scanning results are returned.
  4. Iterate through the BarcodeDetail array.
  5. Read and output the barcode type, raw text, and formatted ASCII text.

' Scan Code 128 barcode and retrieve detailed barcode information
Dim result As BarcodeDetail() = BarcodeScanner.ScanInDetails(
    "Code128-sample-image.png", BarcodeType.Code128)

' Check if valid barcode results are detected
If result IsNot Nothing AndAlso result.Length > 0 Then
    ' Iterate all scanned barcode records
    For Each barcodeInfo As BarcodeDetail In result
        Console.WriteLine("Barcode Format: {0}", barcodeInfo.Type)
        Console.WriteLine("Code 128 text: {0}", barcodeInfo.GetMessage())
        Console.WriteLine("Code 128 ASCII text: {0}", barcodeInfo.GetASCIITextMessage())
    Next
End If




Code 128 position, rotation, check sum, and encoding mode

You can obtain the geometric information of the scanned Code 128 barcode directly from the BarcodeDetail object.

  • Rotation: Gets the rotation angle of the detected barcode.
  • X1, Y1, X2, Y2, X3, Y3, X4, Y4: Gets the 4 vertex pixel coordinates that define the barcode bounding box in the image.

After obtaining the BarcodeDetail object, you can call the GetBarcodeProps() method.This method returns a Code128Props (Code 128 dedicated property entity) object for advanced decoding information.

  • StartSet: Gets the initial encoding code set used by the Code 128 barcode (A, B, or C).
  • IsMixSet: Returns True if multiple code sets are used in a single barcode.
  • Checksum: Gets the checksum codeword value (valid range: 0 to 102) for data validation.

Here are these steps to extract full Code 128 information in VB.NET:

  1. Call BarcodeScanner.ScanInDetails() to scan the barcode image.
  2. Check for valid scanning results.
  3. Read basic information, rotation angle, and position coordinates.
  4. Cast the barcode properties to Code128Props for advanced data.
  5. Read and output start code set, mixed set status, and checksum value.

' Scan Code 128 barcode and retrieve detailed information
Dim result As BarcodeDetail() = BarcodeScanner.ScanInDetails(
    "Code128-sample-image.png", BarcodeType.Code128)

' Check if valid barcode data is detected
If result IsNot Nothing AndAlso result.Length > 0 Then
    ' Iterate all scanned barcode records
    For Each barcodeInfo As BarcodeDetail In result
        ' Output basic barcode text
        Console.WriteLine("Barcode Format: {0}", barcodeInfo.Type)
        Console.WriteLine("Code 128 text: {0}", barcodeInfo.GetMessage())
        Console.WriteLine("Code 128 ASCII text: {0}", barcodeInfo.GetASCIITextMessage())

        ' Output rotation and position coordinates
        Console.WriteLine("Rotation angle: {0}", barcodeInfo.Rotation)
        Console.WriteLine("Barcode Position X1: {0}, Y1: {1}", barcodeInfo.X1, barcodeInfo.Y1)
        Console.WriteLine("Barcode Position X2: {0}, Y2: {1}", barcodeInfo.X2, barcodeInfo.Y2)
        Console.WriteLine("Barcode Position X3: {0}, Y3: {1}", barcodeInfo.X3, barcodeInfo.Y3)
        Console.WriteLine("Barcode Position X4: {0}, Y4: {1}", barcodeInfo.X4, barcodeInfo.Y4)

        ' Extract advanced Code 128 properties
        If barcodeInfo.Type = BarcodeType.Code128 Then
            Dim props As Code128Props = CType(barcodeInfo.GetBarcodeProps(), Code128Props)
            
            ' Output advanced encoding properties
            Console.WriteLine("Start Set:   {0}", props.StartSet.ToString())
            Console.WriteLine("Is Mix Set:  {0}", props.IsMixSet.ToString())
            Console.WriteLine("Checksum:    {0}", props.Checksum.ToString())
        End If
    Next
End If




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.

You can scan raw barcode data and manually replace control characters with readable labels using VB.NET Barcode Reader library.

  1. Call BarcodeScanner.Scan() to decode the Code 128 image.
  2. Iterate through the returned text results.
  3. Replace the carriage return character \r with the label [CR].
  4. Output both raw and formatted text messages.

' Scan Code 128 barcode with control characters
Dim result As String() = BarcodeScanner.Scan(
    "C:\Input\code128-none-printable-chars.png", BarcodeType.Code128)

' Process and display raw and formatted messages
For Each msg As String In result
    Debug.WriteLine("Barcode Raw Message: '" & msg & "'")
    ' Replace carriage return control character with [CR]
    Dim tmp As String = msg.Replace(vbCr, "[CR]")
    Debug.WriteLine("Barcode Message: '" & tmp & "'")
Next


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

  1. Create a ScanOptions object for Code 128.
  2. Scan the image using BarcodeScanner.Scan().
  3. Call GetASCIITextMessage() to get the formatted text directly.
  4. Output the processed barcode text.

' Configure scanning options
Dim opts As New ScanOptions(BarcodeType.Code128)

' Scan and retrieve detailed barcode information
Dim datas As BarcodeDetail() = BarcodeScanner.Scan(
    "C:\Input\code128-none-printable-chars.png", opts)

' Get automatically formatted ASCII text
For Each obj As BarcodeDetail In datas
    Debug.WriteLine("Barcode Text: " & obj.GetASCIITextMessage())
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 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 will be returned to your application.

Note:
  1. Do not manually process or remove check characters in VB.NET code.
  2. Damaged, blurry, or modified barcodes will fail validation and return empty results.
  3. Automatic validation ensures data accuracy for industrial and desktop applications.
  4. This feature works for both image files and Stream object inputs.












Common Asked Questions

What is the barcode 128 text code?

Code 128 barcode is a high-density 1D barcode format, which encodes digits, text, control characters, and full ASCII 128 characters. Using VB.NET Barcode Reader library, you will be able to scan, recognize barcode text from images file in VB.NET Windows Forms, WPF applications.

How do you read a Code 128 barcode?

Code 128 barcodes are including four parts:
  • A start character
  • Code 128 data characters
  • A checksum digit
  • A stop character
To read a Code 128 barcode, use a barcode scanner or barcode reader software to scan the image target area and detect the four parts, and decode the Code 128 barcode data. OnBarcode VB.NET Barcode Reader library supports reading and decoding Code 128 barcode images in VB .NET Windows projects.

What scanners read Code 128?

Most commercial barcode scanner devices and free or paid barcode scanner software can read Code 128 barcodes from images or printed papers. OnBarcode VB.NET Barcode Scanner library supports scanning and reading Code 128 barcodes in VB .NET app on Windows, macOS and Linux.

How do I scan a Code 128 barcode?

You can easily use a barcode scanner device, a phone or pad with camera, or barcode software or library to scan, decode Code 128 text from barcode images or printed papers.

VB.NET Barcode Reader library will enable your Visual Studio console and Windows apps to scan and recogize all Code 128 and other 2d, 1d barcodes from image files.

How to read Code 128 checksum digit using barcode scanner software?

According to Code 128 ISO standard (ISO/IEC 15417), barcode scanner device or software will not return the Code 128 check sum character. OnBarcode VB.NET Barcode Reader library will recognize and decode the Code 128 data text without the check digit in Visual Basic class.




































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.