.NET Barcode > VB.NET Barcode Generation Guide > VB.NET Code 128 Barcode Library for .NET WinForms, ASP.NET

VB.NET Code 128 Barcode Generator Control


How to Use Visual Basic/VB.NET to Generate Code 128 Barcode Images in .NET Programs
  • Add mature barcode capabilities like barcode image generation and printing supports to .NET Framework-based applications
  • With easy-to-use design, no need for any special or complex configurations for using this VB.NET Barcode Class Library DLL
  • Compiled fully in Visual C#.NET with 100% compatiblity with Visual Studio .NET Framework
  • Directly use .NET Barcode Generator SDK barcoding functions for linear Code 128 barcode generation
  • Generate & print Code 128 1D barcode for ASP.NET, .NET WinForms, .NET Class Library, etc
  • Generate & draw linear Code 128 barcode images on SQL Server Reporting Services for .NET projects
  • Insert & draw Code 128 images on Crystal Reports and RDLC Reports for .NET projects
  • All encoded Code 128 barcodes comply with its latest barcode standards, compatible with almost all printers
  • Provide several license types for ordering this professional Visual Basic Barcoding Component for .NET
This section provides an overview of generating Code 128 barcodes using the BarcodeLib SDK within VB.NET. Code 128, also referred to as ANSI/AIM 128, USS Code 128, or Uniform Symbology Specification Code 128, is a high density linear symbology known for its excellent reliability and comprehensive character support.

The BarcodeLib VB.NET Code 128 Generator is designed for straightforward integration into Windows Forms (WinForms) and Windows Presentation Foundation (WPF) desktop applications, as well as class libraries and console projects.

VB.NET Code 128 Barcode Generator Library

QR Code, Data Matrix, Code 128, GS1, EAN/UPC. Unicode text encoding in VB.NET desktop application.

Download Now
NuGet Ready
.NET 5+
.NET Framework 4.x, 3.x, 2.x


Overview

Linear barcode Code 128 is still called USS Code 128, Code 128 Code Set A, Code 128 Code Set B, Code 128 Code Set C, ANSI/AIM 128, ANSI/AIM Code 128, Uniform Symbology Specification Code 128, Code 128A, Code 128B, Code 128C.
ISO/IEC Standard Compatibility: Complying with ISO/IEC 15417 (Second edition 2007-06-01)
Code 128 Three Code Sets
  • Code Set A (or Chars Set A): all of the standard upper case U.S. alphanumeric keyboard characters and punctuation characters together with the control characters, (i.e. characters with ASCII values from 0 to 95 inclusive), and seven special characters.
  • Code Set B (or Chars Set B): all of the standard upper case alphanumeric keyboard characters and punctuation characters together with the lower case alphabetic characters (i.e. characters with ASCII values from 32 to 127 inclusive), and seven special characters.
  • Code Set C (or Chars Set C): the set of 100 digit pairs from 00 to 99 inclusive, as well as three special characters. This allows numeric data to be encoded as two data digits per symbol character, at effectively twice the density of standard data.
Code 128 Special Characters
The last seven characters of Code Sets A and B (character values 96 - 102) and the last three characters of Code Set C (character values 100 - 102) are special non-data characters with no ASCII character equivalents, which have particular significance to the bar code reading device.

Using BarcodeLib barcode library, you can set the Type property to BarcodeType.CODE128, and the library will determine the correct code set automatically.

If manual selection of the Code 128 code set is required, set the Type property to one of the following:
  • BarcodeType.CODE128A for Code Set A
  • BarcodeType.CODE128B for Code Set B
  • BarcodeType.CODE128C for Code Set C
' Barcode symbology type. Code 128 supports types:
' CODE128, CODE128A, CODE128B, CODE128C.
code128.Type = BarcodeType.CODE128


How to create Code 128 barcode in VB.NET?

  1. Create a new Linear object for 1d (linear) barcodes generation in vb.net
  2. Set property Data with barcode encoding text string
  3. Set property Type with BarcodeType.CODE128 for Code 128 barcode generation
  4. Call method drawBarcode to print Code 128 barcode to an image file
Dim barcode = New Linear()
barcode.Data = "Code 128"
barcode.Type = BarcodeType.CODE128
barcode.drawBarcode("C://Output//vb-net-code128-barcode-sample.png")



Print Code 128 in image objects

You can also easily create and print barcode into a Stream, Graphics, or Byte array object in memory for further processing.

Print Code 128 barcode in Stream object in Visual Basic

  • Use method drawBarcode to print generated Code 128 barcode to a Stream object
Dim barcode = New Linear()
barcode.Data = "Code-128"
barcode.Type = BarcodeType.CODE128

Dim barcodeInStream = New MemoryStream()
barcode.drawBarcode(barcodeInStream)

Print Code 128 barcode in Graphics object in Visual Basic

  • Use method drawBarcode to create and draw Code 128 barcode to a Graphics object. You need customize the barcode image width and height.
Dim barcode = New Linear()
barcode.Data = "Code 128"
barcode.Type = BarcodeType.CODE128
barcode.ImageWidth = 200
barcode.ImageHeight = 150
Dim bitmap = New Bitmap(200, 150)
Dim barcodeInGraphics = Graphics.FromImage(bitmap)
barcode.drawBarcode(barcodeInGraphics)

Print Code 128 barcode in Byte array object in vb.net

  • Use method drawBarcode to encode and output Code 128 barcode to a Byte array object.
Dim barcodeInBytes As Byte() = barcode.drawBarcodeAsBytes()


How to encode ASCII text in Code 128 barcode in vb.net?

Encode ASCII text with control characters in VB.NET

Code 128 supports full ASCII 128 characters encoding. Most of the ASCII characters are printable, and you can input them directly using keyboard. Some control characters are non-printable, you need use the following method to encode in the Code 128 barcode.
  • Enable property ProcessTilde to true.
  • In property Data, you need pass these control character's ASCII integer value in the following format: ~ddd. Here ddd is the ASCII value in 3 digits.
Dim barcode = New Linear()
barcode.Type = BarcodeType.CODE128
barcode.ProcessTilde = True
barcode.Data = "AB~013C-123"



Code 128 Check Digit Character in VB.NET

A mandatory check digit (checksum) character is included in Code 128 barcodes, based on modulo 103 (mod 103). This check digit is not displayed in the human-readable interpretation (barcode text) and is not returned by the barcode decoder.

In the Linear barcode library class, the AddCheckSum property does not apply to Code 128. The library always calculates and appends a check digit character before the stop character.


Create Code 128 barcode with customized size in VB.NET?

  • Set property ImageWidth with the specified Code 128 barcode image width in pixel.
  • Set property ImageHeight with the specified Code 128 barcode image height in pixel.
Dim barcode = New Linear()
barcode.Type = BarcodeType.CODE128
barcode.Data = "Code-128"
barcode.ImageWidth = 300
barcode.ImageHeight = 200



How to print colored Code 128 barcode in VB.NET?

  • Use property BarColor to specify the target Code 128 bar modules' color
  • Use property BackgroundColor to specify the target Code 128 space modules' and backgrond color
  • Use property TextFontColor to specify the Code 128 text label font color
Dim barcode = New Linear()
barcode.Type = BarcodeType.CODE128
barcode.Data = "Code 128"
barcode.BarColor = Color.Red
barcode.BackgroundColor = Color.LightBlue
barcode.TextFontColor = Color.Red



How to create, print Code 128 barcode with customized text label in VB.NET?

Code 128 text font styles

  • Disable property ResizeText to false to manually update the text label font size.
  • Use property TextFont to specify the new Code 128 text label font family, size, font style.
Dim barcode = New Linear()
barcode.Type = BarcodeType.CODE128
barcode.Data = "Code 128"
barcode.ResizeText = False
barcode.TextFont = New Font("OCR-B", 12)



Show, hide Code 128 text label

  • Disable property ShowText to false to not print Code 128 text label in the barcode image.
barcode.ShowText = False



Code 128 text position

  • Use property TextMargin to specify the margin space (in pixel) between bars and printed text string.
barcode.TextMargin = 50



Summary

This guide has provided a comprehensive walkthrough for generating Code 128 barcodes using the BarcodeLib SDK in VB.NET, with particular attention to the flexibility of encoding all 128 ASCII characters and supporting tilde notation for special character representation.

These capabilities are well suited for integration into Windows Forms (WinForms) and Windows Presentation Foundation (WPF) desktop applications, enabling developers to incorporate high density linear barcode generation into their .NET projects. The included code example and list of supported symbologies serve as a practical reference for implementing barcode functionality across a variety of VB.NET application types.
Code 128 VB.NET Barcode Generator Component Supported Barcodes
VB.NET Linear Barcodes:
VB.NET Matrix Barcodes:
VB.NET Code 128 Barcode Component Supported 1D (Linear) Barcodes: Codabar, Code 11, Code 2 of 5, Code 39, Code 93, Code 128, EAN 8, EAN 13, EAN 128, Interleaved 2 of 5, ITF14 (UPC Shipping Container Symbol), MSI Plessey, OneCode, Planet, Postnet, RM4SCC (British Royal Mail 4-State Customer Barcode), UPC-A, UPC-E.
VB.NET Code 128 Barcode Component Supported 2D (Matrix) Barcodes: Data Matrix, PDF417, QR Code.