
How to Generate Barcodes in VB .NET
Barcodes play a crucial role in modern applications, facilitating efficient data tracking and management. In the world of .NET development, there are numerous barcode generator SDKs available and various extensions can be found on the Visual Studio marketplace as well. IronBarcode stands out as a powerful library for generating and reading barcodes. How cool would it be to have a barcode generating .NET Windows application using IronBarcode?
In this article, we will explore how to create a barcode generator in VB.NET using IronBarcode, a versatile tool that simplifies barcode handling within your applications.
How to Generate Barcodes in VB.NET
- Create a VB.NET Console Application in Visual Studio.
- Install IronBarcode Library using NuGet.
- Add a reference to IronBarcode Library in Program.vb file.
- Create Barcode using BarcodeWriter.CreateBarcode Method.
- Save Barcode using SaveAsImage Method.
IronBarcode - The Ultimate .NET Barcode Generator DLL
IronBarcode, part of the Iron Software product line, provides a comprehensive set of functionalities for working with barcodes in .NET applications. It supports various barcode formats, including QR codes, UPC, EAN, Code 128, and more. With its user-friendly API, IronBarcode makes it easy to generate barcodes, read, and customize them in VB.NET projects.
Features of IronBarcode:
Here are some important key features of IronBarcode that make it a number one contender for generating barcodes in Visual Basic:
- Barcode Generation: IronBarcode enables the creation of a wide range of barcode types, including QR code, 2D Data Matrix barcodes, and various linear barcodes.
- Barcode Reading: The library allows developers to read barcodes from images, PDFs, and other sources, providing automatic rotation and perspective correction.
- Styling Options: IronBarcode offers extensive styling options, allowing developers to customize the appearance of barcodes, add text annotations, and include logos.
- Output Formats: Barcodes can be exported in various formats, including images (PNG, JPEG), PDF, HTML, and more.
- Compatibility: IronBarcode is compatible with a range of .NET languages, including VB.NET, and supports multiple platforms such as .NET Core, .NET Standard, and .NET Framework.
Steps to Create a VB.NET Console Project in Visual Studio
-
Open Visual Studio and select "Create a new project."
-
Choose "Console App (.NET Core/.NET Framework)" as the project template.
-
Set a name for your project and click "Next."

-
From Additional Information, choose the appropriate .NET version. IronBarcode supports the latest 8.0 version so you can choose that without any hesitation.
Install IronBarcode via NuGet Package Manager Console or Solutions
To integrate IronBarcode into your VB.NET project to generate linear barcodes, follow these steps:
-
NuGet Package Manager Console:
-
Open the NuGet Package Manager Console from the tools menu in Visual Studio.
-
Run the following command to install IronBarcode:
-
-
Solution Explorer:
- Right-click on your project in Solution Explorer.
- Select "Manage NuGet Packages."
- Search for "Barcode" in the browse tab and install the IronBarcode package.

Steps to Generate Barcode in VB.NET
Now that IronBarcode is integrated into the VB.NET console application, let's create a barcode using IronBarcode that generates a barcode.
-
Importing Libraries:
Imports IronBarCode Imports System.IOVB .NETIn the first two lines, necessary libraries are imported. IronBarcode provides the functionality for working with barcodes, and System.IO is imported for handling input/output operations.
-
Creating a Simple Barcode:
Dim myBarcode = BarcodeWriter.CreateBarcode("1212345", BarcodeWriterEncoding.EAN8)VB .NETHere, a barcode is created with the value "1212345" and the encoding type EAN8 using BarcodeWriter.CreateBarcode method. The resulting barcode is stored in the myBarcode variable.
-
Saving the Barcode as an Image:
myBarcode.SaveAsImage("EAN8.jpeg")VB .NETThe generated barcode (myBarcode) is saved as an image file named "EAN8.jpeg" using the SaveAsImage method.
-
One-Liner for Creating and Saving Barcode:
BarcodeWriter.CreateBarcode("1212345", BarcodeWriterEncoding.EAN8).ResizeTo(300, 200).SaveAsImage("EAN8.jpeg")VB .NETThis line combines the barcode creation, resizing (to 300x200), and saving into a single line of code.
-
Creating a barcode from binary data (byte array):
Dim payloadAsString As String = "This is some random string" Dim payloadAsByteArray() As Byte = System.Text.Encoding.Default.GetBytes(payloadAsString) Dim AztecBarcode = BarcodeWriter.CreateBarcode(payloadAsByteArray, BarcodeWriterEncoding.Aztec, 400, 400) AztecBarcode.SaveAsImage("AztecBarcode.png")VB .NETHere, we convert a string to a byte array (payloadAsByteArray) and then create a barcode (AztecBarcode) using the Aztec encoding type with dimensions 400x400.
-
Creating a barcode from binary data (MemoryStream):
Dim payloadAsStream As New MemoryStream(payloadAsByteArray) Dim AztecBarcode2 = BarcodeWriter.CreateBarcode(payloadAsStream, BarcodeWriterEncoding.Aztec, 400, 400) AztecBarcode2.SaveAsImage("AztecBarcode2.png")VB .NETIn this step, we create a MemoryStream from the byte array and then generate another barcode (AztecBarcode2) using the Aztec encoding type with dimensions 400x400.
-
Saving the Barcode in multiple formats:
myBarcode.SaveAsImage("MyBarcode.png") myBarcode.SaveAsGif("MyBarcode.gif") myBarcode.SaveAsHtmlFile("MyBarcode.html") myBarcode.SaveAsJpeg("MyBarcode.jpg") myBarcode.SaveAsPdf("MyBarcode.Pdf") myBarcode.SaveAsPng("MyBarcode.png") myBarcode.SaveAsTiff("MyBarcode.tiff") myBarcode.SaveAsWindowsBitmap("MyBarcode.bmp")VB .NETThese lines demonstrate how the generated barcode (myBarcode) can be saved in various image formats such as PNG, GIF, HTML, JPEG, PDF, TIFF, and Windows Bitmap. IronBarcode provides flexibility in choosing the desired output format for the generated barcode.
Each step demonstrates different ways to create barcodes with IronBarcode, whether from simple values, binary data, or in a concise one-liner. The source code showcases the flexibility and ease of use offered by IronBarcode in VB Programming.
For more controlled barcode generation and styling, please visit this code examples page.
The complete Visual Basic sample code goes as follows:
Imports IronBarCode
Imports System.IO
Module Program
Sub Main(args As String())
' Creating a simple barcode with EAN8 encoding
Dim myBarcode = BarcodeWriter.CreateBarcode("1212345", BarcodeWriterEncoding.EAN8)
' Save barcode as an image
myBarcode.SaveAsImage("EAN8.jpeg")
' One-liner to create and resize barcode
BarcodeWriter.CreateBarcode("1212345", BarcodeWriterEncoding.EAN8).ResizeTo(400, 100).SaveAsImage("EAN8.jpeg")
' Barcode creation from Binary data (byte array and MemoryStream)
Dim payloadAsString As String = "This is some random string"
Dim payloadAsByteArray() As Byte = System.Text.Encoding.Default.GetBytes(payloadAsString) ' Convert String to Byte Array
Dim AztecBarcode = BarcodeWriter.CreateBarcode(payloadAsByteArray, BarcodeWriterEncoding.Aztec, 400, 400) ' Create barcode from Byte Array
Dim payloadAsStream As New MemoryStream(payloadAsByteArray) ' Create MemoryStream
Dim AztecBarcode2 = BarcodeWriter.CreateBarcode(payloadAsStream, BarcodeWriterEncoding.Aztec, 400, 400) ' Create barcode from Memory Stream
' Save AztecBarcode as an image
AztecBarcode.SaveAsImage("AztecBarcode.png")
End Sub
End Module
Output Barcode Image
Upon running the VB.NET console application, a barcode image file ("EAN8.jpeg") and a QR code type AztecBarcode image file ("AztecBarcode.png") will be created in the project folder.


IronBarcode can also be easily integrated into .NET Windows Forms and ASP.NET Web projects.
Conclusion
In this article, we've explored how to create a VB.NET barcode generator using the IronBarcode library. By following the steps outlined, developers can seamlessly integrate barcode generation capabilities into their VB.NET applications, enhancing data tracking and management. IronBarcode's rich feature set and straightforward API make it a valuable tool for barcode-related tasks in the .NET ecosystem.
For more detailed information on IronBarcode and its usage, please visit the documentation page.
IronBarcode is free for development purposes; however, it needs to be licensed to test out its full potential in handling barcode images in VB.NET Barcode applications. Download the library from here and give it a try.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.
Related Articles


