USING IRONBARCODE

How to Generate Barcode in VB.NET

Barcodes can be used to present data in a visible, computer-readable format. Initially, data in barcodes was represented by parallel lines that were spaced, widened, and sized differently. Various specialized optical scanners, known as barcode readers, can read these contemporary linear or one-dimensional (1D) barcodes. Later, two-dimensional (2D) variants of linear barcodes, which do not really employ bars, were developed and are known as matrix codes or 2D barcodes. Instead of using the standard barcodes, these versions employ rectangles, dots, hexagons, and other patterns. Various configurations of 2D optical scanners, made exclusively to read 2D barcodes, are available. A digital camera connected to a computer that runs software to take a photo of the barcode and decode it using the image is another way to read 2D barcodes. A mobile device with an inbuilt camera, such as a smartphone, can use the latter type of 2D barcode scanner by installing specific application software.

IronBarcode Features

The IronBarcode Library makes it simple to create dynamic barcodes. It helps us to encode barcode images with just a few lines of code. This straightforward library can create a barcode. Strong barcode generators built inside IronBarcode barcode readers allow them to create high-quality barcodes. IronBarcode allows us to create barcodes in VB.NET, C#, etc. Among various .NET libraries, this barcode generator simplifies reading your barcode using the barcode scanner.

  • IronBarcode can read and write most barcode image formats and QR standards, such as UPC A/E, Databar, EAN 8/13, MSI, Code 39/93/128, CodaBar, RSS 14/Expanded, and ITF.
  • It can correct rotation, noise, distortion, and skewing when reading scans and real-time video frames. IronBarcode automatically preprocesses barcode images while creating them to increase reading accuracy and speed.
  • IronBarcode supports batch processing with multi-core and multi-thread capabilities, beneficial for servers.
  • It can automatically locate one or more barcodes in single- and multipage documents.
  • IronBarcode is compatible with both the .NET Framework and .NET Core, supporting both 32-bit and 64-bit architectures.
  • On PC and mobile platforms, IronBarcode supports console, desktop, cloud, and internet applications.
  • IronBarcode can produce barcode images in various file and stream types, including PDF, JPG, TIFF, GIF, BMP, PNG, and HTML.

Creating a New Project in Visual Studio

Open Visual Studio, choose "New Project" from the file menu, then "Console App," "Windows Forms," or "WPF Application." In this article, we will be creating a Visual Basic Console App.

How to Generate Barcode in VB.NET: Figure 1

In the relevant text box, type the project name and choose the file path. Click the "Next" button.

How to Generate Barcode in VB.NET: Figure 2

Select the necessary .NET framework; for our tutorial, we are selecting .NET 6.0 and then clicking the "Create" button to create the project.

How to Generate Barcode in VB.NET: Figure 3

If you choose a console application, the project will now create the structure for that application and open the Program.cs file. You can now enter code and compile the program.

Next, download and install the IronBarcode library using the NuGet Package Manager command:

Install-Package BarCode

How to Generate Barcode in VB.NET: Figure 4

Alternatively, you can search for and download the "Barcode" package using the NuGet Package Manager, which will display all the search results. You can then choose the necessary package to download from them into the application.

How to Generate Barcode in VB.NET: Figure 5

Generate Barcode Using IronBarcode

Here is a sample VB.NET code for generating a barcode label using IronBarcode.

Imports System
Imports IronBarCode

Module Program
    Sub Main(args As String())
        ' Create a barcode with the text "Hello world" using Code128 encoding
        Dim barcode = BarcodeWriter.CreateBarcode("Hello world", BarcodeWriterEncoding.Code128, 500, 500)

        ' Add the barcode value text below the barcode
        barcode.AddBarcodeValueTextBelowBarcode()

        ' Save the barcode as a PNG image file
        barcode.SaveAsPng("demo.png")
    End Sub
End Module
Imports System
Imports IronBarCode

Module Program
    Sub Main(args As String())
        ' Create a barcode with the text "Hello world" using Code128 encoding
        Dim barcode = BarcodeWriter.CreateBarcode("Hello world", BarcodeWriterEncoding.Code128, 500, 500)

        ' Add the barcode value text below the barcode
        barcode.AddBarcodeValueTextBelowBarcode()

        ' Save the barcode as a PNG image file
        barcode.SaveAsPng("demo.png")
    End Sub
End Module
VB .NET

Explanation:

  • CreateBarcode: This function creates a barcode image with the given data. It takes parameters for the barcode content ("Hello world"), encoding type (BarcodeWriterEncoding.Code128), and dimensions (500x500 pixels).
  • AddBarcodeValueTextBelowBarcode: This method adds the encoded text below the barcode image.
  • SaveAsPng: This method saves the barcode image to the file path specified as "demo.png".

IronBarcode provides various options to create barcode images with different features, allowing adjustment and correction to provide high-quality images. We can also generate barcodes from text, streams, URLs, and other sources.

The output of the above code to generate barcodes in VB.NET using IronBarcode will look like below:

How to Generate Barcode in VB.NET: Figure 6

To know more about generating barcodes, click here for the tutorial.

Conclusion

Due to its effectiveness and adaptability to different operating systems, the IronBarcode library is an excellent choice for creating and identifying barcodes.

It provides numerous tools for designing and modifying various barcode kinds, including options to change text, barcode data color, line width, and height. Using VB.NET Crystal Reports is also supported by this barcode generator SDK, facilitating barcode creation and drawing in VB.NET.

The IronBarcode website, which offers both commercial and free versions for developers, contains licensing information about the library. Updates and support are offered without charge for a year.

Frequently Asked Questions

How can I create a barcode using VB.NET?

You can create a barcode in VB.NET using the IronBarcode library. Install the IronBarcode package via NuGet, and use the BarcodeWriter.CreateBarcode method to generate a barcode.

What types of barcodes can be generated programmatically?

Using IronBarcode, you can generate various barcode formats including UPC A/E, Databar, EAN 8/13, MSI, Code 39/93/128, CodaBar, RSS 14/Expanded, ITF, and QR codes.

Is it possible to support barcode scanning in applications?

Yes, with IronBarcode, you can support barcode scanning and it can correct rotation, noise, distortion, and skewing in barcode images for improved reading accuracy.

Are .NET Core applications supported for barcode generation?

Yes, IronBarcode is compatible with both .NET Framework and .NET Core, supporting 32-bit and 64-bit architectures.

What platforms are supported for barcode applications?

IronBarcode supports console, desktop, cloud, and internet applications on both PC and mobile platforms.

How can a library be installed for barcode functionalities in a project?

You can install the IronBarcode library using the NuGet Package Manager with the command: Install-Package IronBarCode.

Is batch processing of barcodes possible?

Yes, IronBarcode supports batch processing with multi-core and multi-thread capabilities, which is beneficial for processing on servers.

What file formats can be used to output barcode images?

IronBarcode can output barcode images to various file formats including PDF, JPG, TIFF, GIF, BMP, PNG, and HTML.

Are there any licensing options available for barcode generation libraries?

Yes, the IronBarcode website offers both commercial and free versions for developers, with free updates and support available for a year.

What are some features available in libraries for barcode generation?

IronBarcode allows for encoding barcode images with minimal code, supports high-quality barcode generation, automatic image preprocessing, batch processing, and compatibility with multiple platforms and frameworks.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he says it’s one of his favorite aspects of working with Iron Software. Jordi grew up in Miami, Florida and studied Computer Science and Statistics at University of Florida.
< PREVIOUS
How to Integrate Barcode Scanner into Web Application
NEXT >
How to Generate QR Codes in ASP.NET MVC