VB.NET Code 128 Generator Size Setting Tutorial

sample source code to generate linear Code 128 images and adjust barcode size in VB.NET

  • Easy to be installed in VB.NET IDEs
  • Reusable once being installed
  • Support Code Set A, B, and C for Code 128
  • Add intelligent Code Set auto to simplify data encoding
  • Print flexible margins around Code 128 Symbol
  • Support symbol and background color setting
  • Generate GIF, TIFF, BMP, PNG, and JPEG
  • Compatible with ISO / IEC 15417 (2nd edition 2007-06-01)

Code 128, also known as ANSI/AIM 128, ANSI/AIM Code 128, USS Code 128, Uniform Symbology Specification Code 128, is a very capable linear barcode of excellent density, high reliability.

How to generate, print barcode using .NET, Java sdk library control with example project source code free download:

Code 128 Symbology Structure

W: the width of Code 128, controlled by property BarCodeWidth

C: the number of start, special, symbol check and stop characters plus the number of the data characters not included in D (i.e. C=3 + special char +not double-density data char) ; related to property Data

X (X ≥ 1 pixel): the width of a module bar, controlled by property X

Q (Q ≥ 10X): the width of the quiet zone, related to property LeftMargin & RightMargin

D: the number of numeric data characters encoded in double density (Code Set C) ; related to property Data

More information about Code 128 barcode settings in VB.NET Barcode Generator,please see:


Code 128 VB.NET Generator Size Setting Tutorial

After Code 128 VB.NET Generator installation, get it ready in VB.NET by placing the following statement:

Code 128 with auto Code set

Dim code128 As OnBarcode.Barcode.Linear code128 = New OnBarcode.Barcode.Linear code128.Type = OnBarcode.Barcode.BarcodeType.CODE128

Code 128 Code Set A

Dim code128 As OnBarcode.Barcode.Linear

code128 = New OnBarcode.Barcode.Linear

code128.Type = OnBarcode.Barcode.BarcodeType.CODE128A

Code 128 Code Set B

Dim code128 As OnBarcode.Barcode.Linear

code128 = New OnBarcode.Barcode.Linear

code128.Type = OnBarcode.Barcode.BarcodeType.CODE128B

Code 128 Code Set C

Dim code128 As OnBarcode.Barcode.Linear

code128 = New OnBarcode.Barcode.Linear

code128.Type = OnBarcode.Barcode.BarcodeType.CODE128C


UOM is the controller of size setting unit. Pixel, Cm, and Inch are provided as its options. The default value of UOM is Pixel. For example, type the following statement to select Pixel as the unit of size setting measure:

code128.UOM = OnBarcode.Barcode.UnitOfMeasure.PIXEL

X & Y

Property X (Type: Float; Default: 1) and Property Y (Type: Float; Default: 60) are used in Code 128 barcode symbol size setting. X is for the module width setting, and Y controls the height of the bar.

Sample usage:

code128.X = 2

code128.Y = 70

BarCodeHeight & BarCodeWidth

Property BarCodeHeight (Type: Float; Default: 0) and Property BarCodeWidth (Type: Float; Default: 0) to set the size of the whole image.

Sample usage:

code128.BarcodeHeight = 60

code128.BarcodeWidth = 175


When the value of X, Y, BarCodeWidth, and BarCodeHeight conflict with each other, Property AutoResize (Type: bool; Default: False) should be enabled to solve the problem and make the Code 128 100% compatible with its symbology specification and ISO / IEC 15417. See Code 128 Barcode Size in VB.NET to know more usage of AutoResize.

Sample usage:

code128.X = 2

code128.BarcodeHeight = 60

code128.AutoResize = True

TopMargin, BottomMargin, LeftMargin, & RightMargin

Using Code 128 VB.NET Generator, a quiet zone with 10X width will be generated automatically at each side of the Code 128. When wider quiet zone is needed, you can increase the value of properties LeftMargin (Type: Float; Default: 0) and RightMargin (Type: Float; Default: 0). You can also create margins using TopMargin (Type: Float; Default: 0) and BottomMargin (Type: Float; Default: 0).

Sample usage:

code128.TopMargin = 10

code128.BottomMargin = 10

code128.LeftMargin = 10

code128.RightMargin = 10


Human readable text are required in almost every linear barcode symbology. Property TextMargin (Type: Float; Default: 6 pixel) is used to set the space between Code 128 bar code and the human readable text below the barcode.

Sample usage:

code128.TextMargin = 10

OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.