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.
Create an OptimizeSetting instance configured specifically for CODE128 barcode decoding.
Use method BarcodeReader.ReadBarcode() to read all barcodes from the specified image file using the optimization settings.
Iterate through each detected barcode in the result array. Retrieve the decoded text message from the current barcode
DimoptionsAsNewOptimizeSetting(BarcodeReader.CODE128)
DimbarcodesAsBarCode() =BarcodeReader.ReadBarcode("code128-barcode.png", options)
ForEachbarcodeAsBarCodeInbarcodesDimbarcodeTextAsString=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.
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.
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.
DimoptionsAsNewOptimizeSetting(BarcodeReader.CODE128)
DimdatasAsBarCode() =BarcodeReader.ReadBarcode("code128-barcodes-sample.png", options)
ForEachaBarcodeAsBarCodeIndatasDimbarcodeInfoAsCode128Info=DirectCast(aBarcode.getBarcodeExtraInfos(), Code128Info)
DimstartSetAsCode128Set=barcodeInfo.getFirstSet()
DimisMutlipleSetsAsBoolean=barcodeInfo.hasMultiSets()
DimchecksumCodewordAsInteger=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.
DimoptionsAsNewOptimizeSetting(BarcodeReader.CODE128)
DimdatasAsBarCode() =BarcodeReader.ReadBarcode("code128-barcode-sample.png", options)
ForEachaBarcodeAsBarCodeIndatasDimdataAsciiAsString=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.