QR Code Image Sample - pqScan.com
C#, VB.NET Barcode Creator Encoding Barcode Image in C# and VB.NET Online Demo Download Trial Purchase Now

How to Generate Data Matrix in C# and VB.NET

back to home  >  .NET Barcode Generator SDK  >   Generate Barcodes in C# & VB.NET  >  Generate Data Matrix in C# & VB.NET

Using C# and VB.NET Data Matrix Creator to generate Data Matrix barcode is a simple and easy job. C#/VB Data Matrix Creator SDK can be compatible with any .NET application, and it can make amazing perfect Data Matrix barcode image. Don't hesitate, just encode your Data Matrix barcode now.

In this document, C# and VB.NET samples are provided to introduce you how to generate Data Matrix in .NET class. If you want to make things easier, .NET Winforms Data Matrix Control and ASP.NET Web Data Matrix Control are just right for you.

Generate and encode Data Matrix - Sharp sample

Generating Data Matrix barcode is so easy. Look at the following C# sample code.

using System;
using System.Drawing;
using System.Drawing.Imaging;
using PQScan.BarcodeCreator;

namespace DataMatrixGeneratorInCSharp
{
    classProgram
    {
        staticvoid Main(string[] args)
        {

            //Create an instance of PQScan.BarcodeCreator.Barcode object.
            Barcode datamatrix = new Barcode();
            //Set barcode date to encode
            datamatrix.Data = "pqScan123456789";
            //Set barcode type
            datamatrix.BarType = BarCodeType.DataMatrix;
            //Set barcode image width
            datamatrix.Width = 300;
            //Set barcode image height
            datamatrix.Height = 300;
            //Set datamatrix shape mode: rectangle or square
            datamatrix.DataMatrixShape = SymbolShapeMode.Auto;           
            //Set barcode image fore groud color
            datamatrix.BarcodeColor = Color.Black;
            //Set barcode image back ground color
            datamatrix.BackgroundColor = Color.White;
            //Set barcode image format
            datamatrix.PictureFormat = ImageFormat.Tiff;
            //Save barcode image to file
            datamatrix.CreateBarcode("datamatrix-csharp.tif");    
        }
    }
}

Create and print Data Matrix - Visual Basic sample

Creating Data Matrix barcode looks very simple and fast with vb.net sample code below.

Imports System.Drawing
Imports System.Drawing.Imaging
Imports PQScan.BarcodeCreator

Namespace DataMatrixGeneratorInVB
    Class Program
        Private Shared Sub Main(args As String())

            'Create an instance of PQScan.BarcodeCreator.Barcode object.
            Dim datamatrix As New Barcode()
            'Set barcode date to encode
            datamatrix.Data = "pqScan123456789"
            'Set barcode type
            datamatrix.BarType = BarCodeType.DataMatrix
            'Set barcode image width
            datamatrix.Width = 300
            'Set barcode image height
            datamatrix.Height = 300
            'Set datamatrix shape mode: rectangle or square
            datamatrix.DataMatrixShape = SymbolShapeMode.Auto
            'Set barcode image fore groud color
            datamatrix.BarcodeColor = Color.Black
            'Set barcode image back ground color
            datamatrix.BackgroundColor = Color.White
            'Set barcode image format
            datamatrix.PictureFormat = ImageFormat.Tiff
            'Save barcode image to file
            datamatrix.CreateBarcode("datamatrix-vb.tif")
        End Sub
    End Class
End Namespace

generate datamatrix in c#/vb.net

.NET Barcode Creator QR Code Creator in C#/VB PDF 417 Creator in C#/VB Aztec Creator in C#/VB EAN 13 Creator in C#/VB EAN 8 Creator in C#/VB UPC A Creator in C#/VB Code 128 Creator in C#/VB Code 39 Creator in C#/VB