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 Code128 in C# and VB.NET

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

C# and VB.NET Code128 Creator is one of the generation functions in pqScan Barcode Creator for .NET. The SDK can be compatible with any .NET application, with the help of it, making an amazing perfectCode128 barcode image is a simple and easy job to you . Don't hesitate, just create your Code128 barcode now.

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

Create and drawCode128 - Sharp sample

To meet allthe requirements of applicationssituation, we provide flexible methods to create Code128: to Bitmap object, to file on the disk, to Stream object and to byte array. In this sample, we will introduce you how to generate Code128 and render it to the local file using C# language.

using System;
using System.Drawing;
using System.Drawing.Imaging;
usingPQScan.BarcodeCreator;

namespaceCode128GeneratorInCSharp
{
    classProgram
    {
        staticvoid Main(string[] args)
        {

            //Create an instance of PQScan.BarcodeCreator.Barcodeobject.
            Barcode code128 = new Barcode();
            //Set barcode date to encode
            code128.Data = "123456789";
            //Set barcode type
            code128.BarType = BarCodeType.Code128;
            //Set barcode image width
            code128.Width = 300;
            //Set barcode image height
            code128.Height = 100;
            //Set 1d barcode human-readable text to display
            code128.ShowText = true;           
            //Set barcode image foregroud color
            code128.BarcodeColor = Color.Black;
            //Set barcode image back ground color
            code128.BackgroundColor = Color.White;
            //Set barcode image format
            code128.PictureFormat = ImageFormat.Jpeg;
            //Save barcode image to file
            code128.CreateBarcode("code128-csharp.jpg");
        }
    }
}

Make and print Code128 - Visual Basic sample

In the second example, encoding Code 128 using VB.NET language code is supported. You can get a Code128 easily using following code.

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

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

            'Create an instance of PQScan.BarcodeCreator.Barcode object.
            Dim code128 As New Barcode()
            'Set barcode date to encode
            code128.Data = "123456789"
            'Set barcode type
            code128.BarType = BarCodeType.Code128
            'Set barcode image width
            code128.Width = 300
            'Set barcode image height
            code128.Height = 100
            'Set 1d barcode human-readable text to display
            code128.ShowText = True
            'Set barcode image foregroud color
            code128.BarcodeColor = Color.Black
            'Set barcode image back ground color
            code128.BackgroundColor = Color.White
            'Set barcode image format
            code128.PictureFormat = ImageFormat.Jpeg
            'Save barcode image to file
            code128.CreateBarcode("code128-vb.jpg")
        End Sub
    End Class
End Namespace

generate code128 in c#/vb.net

.NET Barcode Creator QR Code Creator in C#/VB Data Matrix 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 39 Creator in C#/VB