Quick to scan GS1-128 / EAN-128 barcode in VB.NET WinForms, WPF application
Here we will explain how to scan, validate, and parse structured data from GS1-128 (GS1 standard barcode using Code 128 as carrier) using VB.NET.
We provide a sample GS1-128 barcode image encoded with standard GS1 data:
(01)09012345678901(17)240915(10)abc123(3930)978112
GS1-128 uses Code 128 as its data carrier and contains AI (Application Identifier) + data pairs.
Follow these steps to read and parse GS1-128 data in VB.NET:
We provide a sample GS1-128 barcode image encoded with standard GS1 data:
(01)09012345678901(17)240915(10)abc123(3930)978112
GS1-128 uses Code 128 as its data carrier and contains AI (Application Identifier) + data pairs.
Key Processing Rules
-
GS1-128 is recognized by setting the barcode type to
BarcodeType.Code128. - Use
IsGS1Compatibleto verify GS1 standard compliance. - Use
GetMessage()to obtain formatted AIādata string output. - Parse AI pairs by splitting on
(and)delimiters.
Follow these steps to read and parse GS1-128 data in VB.NET:
- Set the scanning type to
BarcodeType.Code128. - Call
BarcodeScanner.ScanInDetails()to read the image. - Check if the barcode is GS1 compliant using
IsGS1Compatible. - Get the formatted GS1 message with
GetMessage(). - Split the message to extract AI and corresponding data pairs.
' Define the input image file path Dim inputFilePath As String = "W:\Projects\Test-Input\gs1-sample-data-gs1-128.png" ' Scan GS1-128 (Code 128) barcode from image Dim result As BarcodeDetail() = BarcodeScanner.ScanInDetails(inputFilePath, BarcodeType.Code128) ' Process each detected barcode For Each b As BarcodeDetail In result ' Check if the barcode follows GS1 standard If b.IsGS1Compatible Then ' Get formatted GS1 message (e.g., (01)09012345678901(17)240915) Dim msg As String = b.GetMessage() Console.WriteLine("Data: '{0}'", b.Data) Console.WriteLine("Message: {0}", msg) ' Split AI and data using ( and ) delimiters Dim vals As String() = msg.Split({"("c, ")"c}, StringSplitOptions.RemoveEmptyEntries) ' Extract and display AI + Data pairs For i As Integer = 0 To vals.Length - 1 Step 2 Console.WriteLine("AI: {0}", vals(i)) Console.WriteLine("Data: {0}", vals(i + 1)) Next End If Next
