How to Generate Barcode in ASP.NET Using VB.NET

Step-by-step guide to create barcode images in ASP.NET website using VB.NET class method with samples
Barcode in ASP.NET
Demo now
License & Price
2D Barcode for ASP.NET
1D Barcode for ASP.NET
Barcode in ASP.NET
Barcode Library DLL/SDK to Create Barcode Image in ASP.NET Using VB.NET - Overview
ASP.NET Server Barcode Control & Generator DLL/SDK is a professional barcode generation component based on .NET framework in Visual Studio to generate & print barcode images dynamically in ASP.NET website, web pages, html pages, aspx pages and other ASP.NET applications. This barcode dll is purely managed code written in C#, and compatible with Visual Basic.NET, managed C++, etc.
This article tells about the detail guide of how to create barcode images in ASP.NET using VB.NET with samples. C# barcode programmers may refer to generate & develop barcode images in ASP.NET using C# with free trial barcode DLL. Common developers may interest in generating barcode images in ASP.NET using IIS and barcode control dll.
Create Barcode in ASP.NET Using VB.NET with Samples - Prerequisites and Development
  • Terrek Barcode Generator DLL for Windows Applications
  • Microsoft .NET Framework 2.0, 3.0, 4.0 or above
  • Microsoft Visual Studio 2005 / 2008 / 2010 (any version)
  • Visual Basic.NET (any version)
  • OS system above Windows 2000, such as Windows XP, Windows Vista, Windows 7, etc
Solution Project Development
  • ASP.NET Web Site (design-time and runtime support)
  • Console Application (runtime support)
  • Class Library (runtime support)
  • ASP.NET Web Services (runtime support)
DLL for Barcode in ASP.NET Using VB.NET - Installation
It is an easy-to-use barcode dll package for easy installation and distribution. This barcode DLL including features and functions of 40+ linear and 2D barcodes are compiled together. VB.NET class encodes data into the appropriate symbology format and sends the barcode string to the default printer. But the barcode control DLL should be correct installed in VB.NET project.
Install Barcode Generator & Library DLL in VB.NET ASP.NET
  • Download barcode generator control SDK for ASP.NET and unzip
  • Copy barcode DLL in the VB.NET project directory in hard drive where the project created
  • Copy documents barcode.aspx and barcode.aspx.cs to the folder where you generate barcode
  • Add the ASP.NET barcode dll file to the project reference in Visual Studio 2005, 2008 or 2010
using Terrek.Barcode;
BarcodeControl barcode = new BarcodeControl();
//Set barcode type, encode data, resize and UOM properties
code39.I = 1.0f;
barcode. Symbol = BarcodeSymbol.Code39;
barcode.BarcodeData = "TRCODE39";
barcode.ImageResize = true;
barcode.MeasuringUnit = MeasuringUnit.PIXEL;
//Code 39 module width and height
barcode.BarWidth = 1;
barcode.BarHeight =40;
//Customize Code 39 human-readable character with font, color and margin
barcode.TextStyle = new Font("Arial", 9f, FontStyle.Regular);
barcode.TextColor = Color.Black;
barcode.TextSpace = 6;
//Specify Code 39 barcode image
barcode.DotsPerInch = 96;
barcode.Rotation = Rotation.Degree0;
barcode.BarcodeFormat = System.Drawing.Imaging.ImageFormat.Png;
//Specify Code 39 barcode image color
barcode. ImageColor = Color.White;
barcode. BarColor = Color.Black;
//Drawing & printing barcode to .NET Graphics, Stream & Bitmap objects
public Bitmap createBarcode ();
public byte[] createBarcodeToByteArray();
public void createBarcode (Graphics graphics);
public void createBarcode (string filename);
public void createBarcode (Stream fileStream);
Using VB.NET to Put Barcode Images into ASP.NET with Barcode DLL - Barcode Image Generation
  • Start your Visual Studio 2005, 2008 and 2010
  • Create a web application using the installed project templates in VB.NET projects;
  • Right-click the project in the solution explorer, and add a reference
  • Right click on the Default.aspx and select View Code
  • In Default.aspx.vb form, copy the following sample VB.NET code accordingly in ASP.NET project
Sample VB.NET Coding to Generate Barcode Images in ASP.NET Project
We use the example of VB.NET generation code to create Data Matrix in ASP.NET web. To create other barcode image, just change the barcode symbols accordingly and modify relevant barcode properties.
Dim DataMatrix As Terrek.Barcode.DotNET.DotNETControl = New Terrek.Barcode.DotNET.DotNETControl
DataMatrix.Symbol = Terrek.Barcode.BarcodeSymbol.DataMatrix
'Data Matrix valid character set, including standard ASCII and extended ASCII
DataMatrix.BarcodeData = "DataMatrix"
'Data Matrix data mode, including Auto, ASCII, C40, Text, X12, Edifact and Base256
DataMatrix.DataMatrixDataMode = Terrek.Barcode.DataMatrixDataMode.Auto
'Data Matrix format mode, ranging from 8*8 to 144*144
DataMatrix.FormatMode = Terrek.Barcode.DataMatrixFormatMode.Format_36X36
'Data Matrix resize and UOM setting
DataMatrix.ImageResize = True
DataMatrix.MeasuringUnit = Terrek.Barcode.MeasuringUnit.PIXEL
'Data Matrix use "~" to encode ACSII special character, set to true to encode those special characters
DataMatrix.Tilde = False
'Data Matrix structured append function, set true to apply structured append function
DataMatrix.StructuredAppend = False
'Data Matrix module width
DataMatrix.BarWidth = 2
'Data Matrix entire image width and height
DataMatrix.ImageWidth = 100
DataMatrix.ImageHeight = 100
' Data Matrix margin size of left, right, top and bottom
DataMatrix.MarginL = 6
DataMatrix.MarginR = 6
DataMatrix.MarginT = 6
DataMatrix.MarginB = 6
' Specify Data Matrix image
DataMatrix.DotsPerInch = 96
DataMatrix.Rotation = Terrek.Barcode.Rotation.Degree0
DataMatrix.BarcodeFormat = System.Drawing.Imaging.ImageFormat.Jpeg
' Specify Data Matrix image color
DataMatrix.ImageColor = Color.White
DataMatrix.BarColor = Color.Black