KA.Barcode for .NET WinForms
How to Print Code 128 in .NET WinForms with Valid Data
Complete Code 39 source code to generate Code 128 images using Barcode Generator for .NET WinForms
  • Create, print 1D Code 128A, Code 128B, Code 128C barcodes in Winforms with .NET control
  • .NET barcode, barcode ASP.NET, barcode .NET WinForms, Excel barcode & Word barcode provided
  • Simple to generate, insert Code 128 barcode images in Crystal Reports and Windows Forms
  • Generating, displaying 1D Code 128 using VB.NET and C#.NET
  • Easy to encode all 128 ISO/IEC 646 characters, function characters, and special characters
  • Provide detailed Excel barcode generation, ASP.NET barcode generation & VB.NET barcode creation guides for users
  • Automatically add system codewords including code set selection characters, and start/stop characters
  • Compute check digit for Code 128 and hide the digit in the human readable text string below symbol
  • Compatible with ISO / IEC 15417 (2nd edition 2007-06-01) for sannable Code 128 output
  • Add auto code set to automatically switch between code set A, B, and C
KA.Barcode Generator for .NET WinForms is a best component API SDK addin software that allows developers to easily create, insert Code 128A, Code 128B and Code 128C in .NET Windows Forms applications, C#.NET, VB.NET class & console applications.
This page will show you how to encode valid data in a Code 128 barcode with detailed C#, VB.NET demo code. Here are two more tutorials for Code 128 generation.
Linear Code 128 Introduction
Code 128, also named ANSI/AIM 128, ANSI/AIM Code 128, USS Code 128, Uniform Symbology Specification Code 128, Code 128 Code Set A, Code 128 Code Set B, Code 128 Code Set C, Code 128A, Code 128B, Code 128C, is a self-checking linear bar code which encodes 128 ISO/IEC 646 characters.

Valid Data

  • Code 128A: A - Z, 0-9, and seven special characters
  • Code 128B: A - Z, a-z, 0-9, and seven special characters
  • Code 128C: digit pairs from 00-99 inclusive, and three special characters

Valid Length

  • Code 128 barcode has a variable symbol length.
Code 128 Data Encoding in KA.Barcode Generator for .NET WinForms

Install Code 128 Barcode Generator into Your .NET Project

  1. 1.
  2. 2.
    Add Reference: Add "KeepAutomation.Barcode.Window.dll"to your .NET WinForms project reference.
  3. 3.
    Add to Toolbox: Add BarCodeControl to your .NET Visual Studio toolbox.
Copy the following barcode procedure demo onto your programs to create, integrate a Code 128 barcode image
using KeepAutomation.Barcode.Bean;
BarCode code128= new BarCode();
code128.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto;
code128.CodeToEncode = "Code128";
code128.X = 3;
code128.generateBarcodeToImageFile("C:/code128_csharp.png");
Dim code128 As KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode

code128.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto
code128.CodeToEncode = "vbCode128"
code128.X = 3
code128.generateBarcodeToImageFile("C://code128 _vb.png")

Encoding AlphaNumeric Data for Code128A

KeepAutomation Code 128A mode can encode all of the standard upper-case alphanumeric characters (A-Z, 0-9) and punctuation characters ( , ; < = > ? @ ) together with the control characters and special characters. Follow the C# Code below to convert alphanumeric data value into a Code 128A barcode.
using KeepAutomation.Barcode.Bean;
BarCode code128= new BarCode();
code128.Symbology = KeepAutomation.Barcode.Symbology.Code128A;
code128.CodeToEncode = "CODE128";
Dim code128 As KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode

code128.Symbology = KeepAutomation.Barcode.Symbology.Code128B
code128.CodeToEncode = "Code128"

Printing Code128B with AlphaNumeric Data

KeepAutomation Code 128B allows you to encode all of the standard upper-case & lower-case alphanumeric characters (A-Z, a-z, 0-9) and punctuation characters as well as control characters. Follow the sample codings below to transform alphanumeric data into a Code 128B barcode.
using KeepAutomation.Barcode.Bean;
BarCode code128= new BarCode();
code128.Symbology = KeepAutomation.Barcode.Symbology.Code128B;
code128.CodeToEncode = "Code128";
Dim code128 As KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode

code128.Symbology = KeepAutomation.Barcode.Symbology.Code128B
code128.CodeToEncode = "Code128"

Geneating Code128C with Numeric String

According to the Code 128 ISO/IEC specification, this barcode control allows you to encode the set of 100 digit pairs from 00-99 inclusive, as well as special characters. This allows numeric data text to be encoded as two data digits per symbol character. Thus if you input odd number of digits, a zero will be added to the end for digit pair encoding.
using KeepAutomation.Barcode.Bean;
BarCode code128= new BarCode();
code128.Symbology = KeepAutomation.Barcode.Symbology.Code128C;
code128.CodeToEncode = "1234";
Dim code128 As KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode

code128.Symbology = KeepAutomation.Barcode.Symbology.Code128C
code128.CodeToEncode = "1234"
Code 128 Data Encoding with Drag & Drop BarcodeControl
  1. 1.
    In "Choose Toolbox Items" form, click button "Browse...", and select KeepAutomation.Barcode.Windows.dll.
  2. 2.
    Now a BarCodeControl is added into your toolbox.
  3. 3.
    Drag and drop the BarCodeControl into the Forms and a Codabar image is generated.
  4. 4.
    Find Symbology" in the property panel and select "Code128Auto" or "Code128A", "Code128B", "Code128C".
  5. 5.
    Then input numeric, alphanumeric or ASCII characters in "CodeToEncode" blanket.
  6. 6.
    A Code 128 image with different characters is successfully created!