How to Generate Barcode Using VB.NET Windows Forms

linear & 2D barcode images are generated dynamically in Windows Forms applications using VB.NET class method
Products
Barcode in .NET WinForms
Tutorial
Demo now
License & Price
2D Barcode for .NET WinForms
1D Barcode for .NET WinForms
Barcode in .NET WinForms
Barcode Generator/Control Component DLL/SDK in VB.NET Windows Applications - Overview
WinForms Barcode Generator Library & Control SDK is an easy-to-use .NET common control designed for developers to create and print linear and 2D barcode images in Windows Forms applications dynamically in .NET framework 2.0, 3.0, 3.5 and 4.0 based on Visual Studio. The generated barcode in Winforms is displayed as images that may be saved in image files such as Gif, Tiff, Bmp, Png or Jpeg, or saved in the memory in byte stream or graphic .NET objects.
This page talks about the detail tutorial of how to create and develop barcode system in Windows Forms project using VB.NET class method, free VB.NET sample code with trial versions are provided for your testament. Terrek also provides the programmer guide for generating barcode images in C#.NET windows applications. Common users may refer to three implementations to create barcode images in .NET WinForms.
Barcode Inserted in Windows Applications Using VB.NET - Requirement and Development
Requirement
  • 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
  • Windows Forms Application (design-time and runtime support)
  • Console Application (runtime support)
  • Class Library (runtime support)
  • Windows Service (runtime support)
  • ASP.NET Web Services (runtime support)
Barcode Library SDK to Create Barcode Using VB.NET Windows Applications - Installation
It is easy and fast to create barcode images in WinForms applications using VB.NET class methods. The embedded barcode symbols and features can be fully displayed by VB.NET code. Before generation, the appropriate barcode component software may be installed in WinForms project using VB.NET.
Install barcode Generator & Control Library DLL in VB.NET Windows Application
  • Download Windows Forms Barcode Creator Component SDK and save it to the local hard drive after unzipping. The DLL document should be saved or copied in the VB.NET Windows application directory where the project developed
  • Open the Visual Studio VB.NET project and add the Windows App barcode system DLL file to the project reference in Solution Explorer
Barcode Control to Create Barcode Using VB.NET Windows Applications - Barcode Generation
  • Install barcode generator and control SDK in VB.NET Windows Applications
  • Drag and drop a button in Toolbox onto the Form
  • Right click on the button and select View Code
  • Copy the following VB.NET code accordingly in WinForms, and debug the project
VB.NET Sample Code to Generate Barcode Images in WinForms Project
VB.NET Sample Code to Generate Barcode Images in WinForms Project
We use the Code 39 sample VB.NET code to create Code 39 in VB.NET Windows applications. To generate other barcode types, just change the barcode symbols and barcode data accordingly. Barcode with special settings are included by using VB.NET class method.
Dim Code39 As Terrek.Barcode.DotNET.DotNETControl = New Terrek.Barcode.DotNET.DotNETControl
'Set barcode type, encode data, resize and UOM properties
Code39.Symbol = Terrek.Barcode.BarcodeSymbol.Code39
Code39.BarcodeData = "TRCODE39"
Code39.ImageResize = True
Code39.MeasuringUnit = Terrek.Barcode.MeasuringUnit.PIXEL
'Code 39 inter-space of characters, it is multiple of X
Code39.InterCharGap = 1.0F
' Code 39 proportion of wide bar and narrow bar, ranging from 2.0 to 3.0
Code39.WideVSNarrow = 2.0F
'Show or hide Code 39 start and stop character "*"
Code39.DisplayAsterisk = False
'Automatically calculate and add checksum symbol
Code39.AutoCheckSum = False
'Display generated Code39 checksum in the text
Code39.ShowCheckSum = True
'Define how the bars are placed in a Code39 image
Code39.BarAlign = Terrek.Barcode.BarAlign.Center
' Code 39 module width and height
Code39.BarWidth = 1
Code39.BarHeight = 40
' Code 39 entire image width and height
Code39.ImageWidth = 100
Code39.ImageHeight = 100
' Code 39 margin size of left, right, top and bottom
Code39.MarginL = 0
Code39.MarginR = 0
Code39.MarginT = 0
Code39.MarginB = 0
' Show or hide Code 39 human-readable character
Code39.DisplayData = True
' Customize Code 39 human-readable character with font, color and margin
Code39.TextStyle = New Font("Arial", 9.0F, FontStyle.Regular)
Code39.TextColor = Color.Black
Code39.TextSpace = 6
' Specify Code 39 image
Code39.DotsPerInch = 96
Code39.Rotation = Terrek.Barcode.Rotation.Degree0
Code39.BarcodeFormat = System.Drawing.Imaging.ImageFormat.Png
Code39.SaveAsImage("C:\code39.png")
' Specify Code 39 image color
Code39.ImageColor = Color.White
Code39.BarColor = Color.Black