How to Create Data Matrix Barcodes Images in .NET with VB
Strictly designed and tested SDK for Data Matrix barcode generation in VB.NET
Perfect integration with .NET Framework applications like ASP.NET and WinForms
Easy to use, without registration code, activation key or other barcode fonts
Adjust Data Matrix barcode image settings with simple VB.NET class library
Offer user-friendly guidance for Visual Basic.NET Data Matrix barcoding
Obtain granted developer license for VB.NET Barcode Control at reasonable price
This guide provides a comprehensive overview of generating Data Matrix barcodes using the BarcodeLib SDK within VB.NET. Data Matrix is a two-dimensional (2D) matrix symbology widely adopted for encoding product information, serial numbers, and other compact data in industries such as manufacturing, logistics, and healthcare.
The BarcodeLib Data Matrix Generator is designed for seamless integration into Windows Forms (WinForms) and Windows Presentation Foundation (WPF) desktop applications, as well as class libraries and console projects.
VB.NET Data Matrix Barcode Image Overview
Data Matrix is a high-density 2D Barcode type whose image looks like a square. Similar to other 2D barcodes, Data Matrix can encode many types of data, including alphanumeric data, byte data and numeric data.
In the real society, Data Matrix has been used in the following sectors like aerospace, defense, healthcare, finance, logistics management, Electronic Industries etc.
Quick to Generate Data Matrix using VB.NET codes
The following steps demonstrate how to generate a Data Matrix barcode using the BarcodeLib VB.NET Data Matrix generator SDK.
Create a DataMatrix object.
Assign the data to be encoded to the Data property.
For example, you might enter a product code or serial number.
Call the drawBarcode() method to output the Data Matrix as an image file. By default, the barcode is rendered in PNG format.
The following VB.NET example consolidates the essential settings for generating a Data Matrix barcode within a class library, Windows Forms, or WPF application. Comments are provided to explain each configuration option.
ImportsBarcodeLib.BarcodeDimbarcodeAsDataMatrix=NewDataMatrix' Data Matrix Barcode Basic Settingsbarcode.Data="112233445566"barcode.DataMode=DataMatrixDataMode.ASCII' Format Mode Selection' If the selected format mode does not have sufficient capacity for the data,' the library will automatically select an appropriate format mode.barcode.FormatMode=DataMatrixFormatMode.Format_48X48' Tilde Processing' Set ProcessTilde = True to use "~" for special characters.' Supported formats:' 1-byte character: ~0dd/~1dd/~2dd (value 000-255)' 2-byte (Unicode): ~6ddddd (value 00000-65535)' GS1 AI codes: ~ai2 through ~ai7' ECI: ~7dddddd' ~rp: Reader Programming (ASCII and Auto modes only)' ~m5: 05 Macro (ASCII and Auto modes only)' ~m6: 06 Macro (ASCII and Auto modes only)barcode.ProcessTilde=True' Size Settingsbarcode.UOM=UnitOfMeasure.PIXELbarcode.X=3barcode.LeftMargin=0barcode.RightMargin=0barcode.TopMargin=0barcode.BottomMargin=0barcode.Resolution=96barcode.Rotate=Rotate.Rotate0' Output Formatbarcode.ImageFormat=System.Drawing.Imaging.ImageFormat.Gif()
' Generate and Savebarcode.drawBarcode("c://data-matrix.gif")
How to create Data Matrix with different text formats in VB.NET?
Encoding Data Matrix wtih ASCII characters
ASCII 128 characters include printing chars and control chars (not printable). You can input the printing ASCII chars in property Data to
create Data Matrix in vb.net program. To encode Data Matrix with control chars, you need process the control chars specially.
Enable property ProcessTilde to true to support ASCII control chars encoding in Data Matrix
In property Data, you need pass each control character's ASCII integer value in the following format: ~ddd. Here ddd is the ASCII value in 3 digits.
Create Data Matrix with Specified Image Width & Height in VB.NET
You can easily create and customize a Data Matrix image with your specified width and height in VB.NET application.
Set Property ImageWidth to the specified image width. Data Matrix is usually in square shape.
barcode.ImageWidth=300;
Note: You only need to enter the image width, and the barcode library will automatically set the image height and generate a square Data Matrix image in
VB.NET application.
Print Rectangle Data Matrix in Visual Basic
When you are generating rectangle Data Matrix image in VB.NET, you need manually set both the Property ImageWidth and ImageHeight.
Create a rectangle Data Matrix with format mode as 16X48.
Set the image width and height through property ImageWidth and ImageHeight
Note: Ensure that the Data Matrix modules are square. In this Data Matrix, the number of modules per row is three times the number of modules per column, so when setting the image size, the width must be three times the height.
Create Data Matrix with advanced options using VB.NET
Data Matrix Format Mode in Visual Basic
The Data Matrix ISO standard defines 24 square symbols and 6 rectangular symbols for ECC 200. Each symbol size has a distinct row and column count, with corresponding data storage capacity.
Using the BarcodeLib VB.NET Data Matrix generation library, you can specify a particular size format mode for the generated barcode. This is useful when you need to conform to fixed size label requirements in WinForms or WPF applications.
The VB.NET code below will create a Data matrix with 32 modules x 32 modules. The printed data matrix barcode has 32 modules (small square) in row and 32 modules in
columns.
barcode.Format=DataMatrixFormat.Format_32X32;
Data Matrix Structured Append in VB.NET
The Data Matrix standard provides a mechanism to split a large data set across multiple barcode symbols. This is analogous to dividing a large file into several smaller volumes, each stored in a separate barcode.
The following VB.NET source code demonstrates how to distribute one message across three Data Matrix barcode images.
Enable Data Matrix Structured Append mode by setting EnableStructuredAppend to True.
Specify the total number of symbols using property StructuredAppendCount.
Assign the current symbol's sequence index via property StructuredAppendIndex. The first symbol should use index 0.
Provide a unique, consistent StructuredAppendFileID value across all symbols that belong to the same Data Matrix data message.
Note: All symbols sharing the same Data Matrix data message must use the same StructuredAppendFileID value.
Ensure the StructuredAppendIndex values are correctly ordered to allow proper reconstruction during Data Matrix image decoding.
Data Matrix FNC1 in VB.NET
When the Function 1 Character (FNC1) appears in the first position of the Data Matrix symbol, it indicates that the encoded data conforms to the GS1 Application Identifier (AI) standard format. This is commonly used in retail and supply chain applications.
To enable GS1 compatible encoding in the BarcodeLib VB.NET Data Matrix generator, set the FNC1Mode property to DataMatrixFNC1Mode.FirstPosition.
barcode.FNC1Mode=DataMatrixFNC1Mode.FirstPosition
Guide to Generate Data Matrix Barcodes in VB.NET WinForms Project
Add BarcodeLib.Barcode.WinForms.dll from the downloaded trial package to your .NET Windows Forms Project.
Add BarcodeLib.Barcode.WinForms.dll to your Visual Studio Toolbox.
You can simply drag the QRCodeWinForm to your windows form, and a QR Code barcode is generated.
Drag DataMatrixWinForm to your windows form and a Data Matrix barcode will be produced or you could use above VB demo code to create Data Matrix.
Other Barcodes Supported by Data Matrix VB.NET Barcode Generator
This guide has provided a detailed walkthrough for generating Data Matrix barcodes using the BarcodeLib SDK in VB.NET. The library supports essential features such as format mode selection, structured append for multi symbol data distribution, and GS1 compatibility via FNC1.
These capabilities are well suited for integration into Windows Forms (WinForms) and Windows Presentation Foundation (WPF) desktop applications, as well as other .NET project types. By following the examples and explanations provided, you can confidently incorporate Data Matrix generation into your VB.NET projects.