Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
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.
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 makes it a number one contender for generating barcodes in Visual Basic:
Set a name for your project and click "Next."
To integrate IronBarcode into your VB.NET project to generate linear barcodes, follow these steps:
NuGet Package Manager Console:
Install-Package IronBarCode
Install-Package IronBarCode
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.IO
Imports IronBarCode
Imports System.IO
In 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)
Dim myBarcode = BarcodeWriter.CreateBarcode("1212345", BarcodeWriterEncoding.EAN8)
Here, 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")
myBarcode.SaveAsImage("EAN8.jpeg")
The 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")
BarcodeWriter.CreateBarcode("1212345", BarcodeWriterEncoding.EAN8).ResizeTo(300, 200).SaveAsImage("EAN8.jpeg")
This 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")
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")
Here, 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")
Dim payloadAsStream As New MemoryStream(payloadAsByteArray)
Dim AztecBarcode2 = BarcodeWriter.CreateBarcode(payloadAsStream, BarcodeWriterEncoding.Aztec, 400, 400)
AztecBarcode2.SaveAsImage("AztecBarcode2.png")
In 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")
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")
These 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
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
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.
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.
IronBarcode is a powerful library for generating and reading barcodes in .NET applications, supporting various formats like QR codes, UPC, EAN, and more.
To create a barcode generator in VB.NET using IronBarcode, you need to create a VB.NET Console Application in Visual Studio, install IronBarcode via NuGet, add a reference to it, and use methods like BarcodeWriter.CreateBarcode to generate barcodes.
IronBarcode supports a wide range of barcode formats, including QR codes, UPC, EAN, Code 128, and 2D Data Matrix barcodes.
You can install IronBarcode in your VB.NET project using the NuGet Package Manager Console by running the command 'Install-Package IronBarCode' or by managing NuGet packages through the Solution Explorer.
Yes, IronBarcode can read barcodes from various sources including images and PDFs, and it provides features like automatic rotation and perspective correction.
IronBarcode offers extensive styling options, allowing developers to customize the appearance of barcodes, add text annotations, and include logos.
Barcodes generated using IronBarcode can be exported in various formats including PNG, JPEG, PDF, HTML, GIF, TIFF, and Windows Bitmap.
Yes, IronBarcode is compatible with various .NET platforms including .NET Core, .NET Standard, and .NET Framework, and supports multiple .NET languages like VB.NET.
Yes, IronBarcode can be integrated into .NET Windows Forms and ASP.NET Web projects, offering flexibility in various application types.
IronBarcode is free for development purposes, but it requires a license to test its full potential in handling barcode images in VB.NET applications.