Przejdź do treści stopki
KORZYSTANIE Z IRONBARCODE

Jak używać kodu kreskowego 2D w VB .NET

Barcodes have become more widely used in the digital era than in the past with linear forms like UPC and EAN. 2D barcodes have revolutionized several sectors and applications by becoming a potent tool for encoding vast volumes of data in a small size. This post will introduce you to the world of a 2D VB.NET barcode and show you how IronBarcode, a popular 2D barcode VB.NET library, makes dealing with 2D barcodes easier so developers can make use of all of its capabilities.

How to Use 2D Barcode in VB .NET

  1. Create a new VB .NET project.
  2. Import IronBarCode net barcode generator DLL.
  3. Create an instance of the BarcodeReader and set the Image Path.
  4. Examine data obtained from barcodes or generate barcodes based on the given data.
  5. Print Information about barcode info/ new barcode images.

What are 2D Barcodes?

Due to its ability to hold data in two dimensions, 2D barcodes—also referred to as matrix barcodes—can encode a far larger amount of data than conventional linear barcodes. Two-dimensional barcodes are made up of a grid of squares, dots, or other geometric patterns as opposed to linear barcodes, which are made up of a single row of bars and spaces.

Compared to their linear predecessors, 2D barcodes have the following benefits:

  • High Data Capacity: 2D barcodes are perfect for applications that need to store a lot of data since they can encode a lot of data, including text, numbers, URLs, and binary data.
  • Error Correction: A lot of 2D barcode systems include error correction built in, so even if a portion of the code is broken or hidden, it can still be read.
  • Small Size: 2D barcodes are small enough to fit on a variety of surfaces, such as labels, identification cards, and product packaging, even though they may hold a large quantity of data.
  • Enhanced Security: To further protect sensitive data, several 2D barcode formats include support for digital signatures and encryption.
  • Popular 2D barcode formats with distinct features include PDF417, Data Matrix, QR codes, and Aztec codes.

IronBarcode

A robust .NET barcode library called IronBarcode makes it easier to create and decode 2D barcodes for use in VB.NET applications. IronBarcode offers thorough support for a wide range of 2D barcode formats, whether you need to produce QR codes for marketing campaigns, encode product information in Data Matrix barcodes, or print PDF417 barcodes for document archiving.

When working with 2D barcodes, IronBarcode's key capabilities include:

  • Broad Format Support: IronBarcode is compatible with a wide range of 2D barcode formats, including Data Matrix barcode, PDF417, QR codes, Aztec codes, and more, guaranteeing conformance with industry standards and a variety of use cases.
  • Adaptable Encoding Options: IronBarcode gives developers complete control over the encoding procedure, enabling them to tailor the produced barcodes' content, size, error correction level, and other characteristics to their own needs.
  • High-quality Rendering: IronBarcode produces barcode pictures that are sharp, aligned precisely, and have crisp borders for maximum reading by barcode scanners and imaging devices.
  • Error Correction: Certain 2D barcode formats that IronBarcode supports include error correction built-in, making it possible for the barcodes to read even under unfavorable circumstances such as partial damage or distortion.

To learn more about the IronBarcode refer here.

Creating a New Project in Visual Studio

With Visual Studio open, choose "New Project" from the file menu, followed by "Console App," .NET Windows Forms project," or "WPF Application." In this post, we'll be using the Visual Basic Console App. Barcodes have several uses in many contexts. Software such as Webform/MVC/MVC Core is an additional choice.

How to Use 2D Barcode in VB .NET: Figure 1 - Open Visual Studio, choose New Project - Select Visual Basic Console App for this post.

In the associated text box, type the project name and choose the file location. Click "Next" to choose.

How to Use 2D Barcode in VB .NET: Figure 2 - Configure the Project name and Location of the project.

Make the necessary option after that. We are selecting a lesson's net structure. After choosing .NET 6.0, you should click "Create" to begin the project.

How to Use 2D Barcode in VB .NET: Figure 3 - Select the .NET 6.0 (Long Term Support) Framework

If you choose to build a console application, the project will now construct the required framework and open the program.cs file so you may add code and run the application.
For the solution to use the IronBarcode library, the required package must be downloaded. To accomplish this via the Package Manager console, use the following command:

Install-Package BarCode

Comparable to the image below:

How to Use 2D Barcode in VB .NET: Figure 4 - To install IronBarcode library, add the following command: install-package BarCode.

Other ways include searching for and downloading the "Barcode" package (which displays all search results) using the NuGet Package Manager. You may then choose which of their programs to download and install on the software after that.

How to Use 2D Barcode in VB .NET: Figure 5 - Install IronBarcode using NuGet Package Manager by searching barcode in the search bar of NuGet Package Manager

2D Barcodes in VB.NET with IronBarcode

Let's now investigate how to use IronBarcode in a VB.NET program to create and decode 2D barcodes.

Generating 2D Barcodes

With IronBarcode, creating 2D barcodes is simple. Here is a VB demo code snippet that shows you how to make a custom barcode and save it as an image file:

Imports IronBarCode

Module Program
    Sub Main()
        ' Create a QR code with the desired content
        Dim qrCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeWriterEncoding.QRCode)

        ' Save the generated QR code as an image file
        qrCode.SaveAsImage("Demo.png")
    End Sub
End Module

To encode data in a barcode, replace "https://ironsoftware.com/csharp/barcode/" with the desired data. Text, URLs, contact details, and other kinds of data may all be encoded with IronBarcode.
The resulting barcode can also have its size, color, error correction level, and encoding mode changed. After it generates the barcode, it may be streamed straight to the output or saved as an image file.

Use the SaveAsImage method to save the barcode as an image file. By doing this, the QR code is saved in the given directory as a PNG image file. Alternatively, you can use the Stream method to stream the barcode straight to the output.

How to Use 2D Barcode in VB .NET: Figure 6 - Output image

Decoding 2D Barcodes

IronBarcode makes 2D barcode decoding incredibly easy. The code sample that shows how to decode a QR code from an image file is provided below:

Imports IronBarCode

Module Program
    Sub Main()
        Dim imagePath As String = "Demo.png"

        ' Read barcodes from the image file
        Dim result = BarcodeReader.Read(imagePath)

        ' Check if any barcode was detected
        If result IsNot Nothing AndAlso result.Count > 0 Then
            ' Iterate over detected barcodes
            For Each barcode In result
                ' Print barcode type and value
                Console.WriteLine($"Barcode Type: {barcode.BarcodeType}")
                Console.WriteLine($"Barcode Value: {barcode.Value}")
            Next
        Else
            Console.WriteLine("No barcode found in the image.")
        End If
    End Sub
End Module

Importing the IronBarcode namespace is the first step towards using the IronBarcode capabilities .NET class. Indicate where the picture file containing the barcode pictures you want to read is located. Replace "Demo.png" with the location of your barcode image files. To read barcodes from a variety of sources, create an instance of the BarcodeReader object.

To read barcode data from the specified image file, use the BarcodeReader's Read method. Check the image to see whether any barcodes are present. Report the type and value of each iteration to the console if barcodes are found. Print a message indicating that the barcode could not be read if it isn't. Below is the result generated from the above barcode image.

How to Use 2D Barcode in VB .NET: Figure 7 - Console Output

To learn more about creating barcodes, view the tutorial by clicking this link.

Wnioski

In summary, 2D barcodes are an effective and adaptable method for compact encoding and decoding vast quantities of data. Using IronBarcode's 2D barcode capabilities in VB.NET applications enables developers to increase productivity, simplify data administration, and enhance user experience in a variety of use cases and industries.

IronBarcode offers the necessary tools and capabilities to fully realize the promise of 2D barcodes in VB.NET applications, whether it's for creating QR codes for marketing campaigns, encoding product information for inventory management, or decoding Data Matrix barcodes for document storage. Developers can effortlessly and confidently fulfill the needs of contemporary data-driven settings by utilizing IronBarcode to enable 2D barcodes in their apps, enabling them to reach new levels of functionality and sophistication.

To know more about IronBarcode's barcoding features, please visit their documentation license for developers. The Lite edition costs $799 and includes free upgrades and support for a full year. Please visit this website to learn more about other Iron Software products.

Często Zadawane Pytania

Czym jest BARCODE 2D i jak się go używa?

2D barcode, or matrix barcode, encodes information in two dimensions using geometric patterns. It is used in various industries to store more data than traditional linear barcodes, offering benefits such as error correction and increased security.

Jak mogę generować i dekodować kody kreskowe 2D w VB.NET?

Aby generować i dekodować kody kreskowe 2D w VB.NET, należy użyć biblioteki takiej jak IronBarcode. Można utworzyć nowy projekt, zaimportować bibliotekę IronBarcode i wykorzystać BarcodeWriter do generowania kodów kreskowych oraz BarcodeReader do ich dekodowania z plików graficznych.

Jakie są popularne formaty BARCODE'ów 2D obsługiwane w projektach VB.NET?

Typowe formaty kodów kreskowych 2D obsługiwane w projektach VB.NET to kody QR, Data Matrix, PDF417 i Aztec. Biblioteki takie jak IronBarcode mogą skutecznie obsługiwać te formaty, zapewniając elastyczne opcje kodowania i wysoką jakość renderowania.

Dlaczego programiści powinni używać kodów kreskowych 2D w aplikacjach?

Programiści powinni korzystać z BARCODE’ów 2D ze względu na ich dużą pojemność danych, możliwości korekcji błędów, kompaktowy rozmiar i ulepszone funkcje bezpieczeństwa, co czyni je idealnymi do zarządzania danymi w różnych zastosowaniach, takich jak zarządzanie zapasami i marketing.

Jakie kroki należy wykonać, aby zintegrować funkcję kodów kreskowych 2D z aplikacją VB.NET?

Zintegrowanie funkcji kodów kreskowych 2D w aplikacji VB.NET wymaga utworzenia projektu w Visual Studio, zaimportowania biblioteki DLL IronBarcode oraz użycia klasy BarcodeReader do odczytu kodów kreskowych z obrazów. Programiści mogą generować kody kreskowe za pomocą klasy BarcodeWriter.

W jaki sposób kody kreskowe 2D zwiększają wydajność w różnych branżach?

Kody kreskowe 2D zwiększają wydajność w branżach takich jak handel detaliczny, logistyka i opieka zdrowotna poprzez usprawnienie zarządzania danymi, optymalizację operacji i zapewnienie lepszego komfortu użytkowania. Biblioteki takie jak IronBarcode ułatwiają osiągnięcie tych korzyści dzięki kompleksowemu wsparciu.

Co sprawia, że kody kreskowe 2D są bardziej korzystne niż kody liniowe?

BarCODE 2D jest bardziej korzystny niż BarCode liniowy, ponieważ przechowuje więcej informacji, w tym tekst i dane binarne, oraz zawiera mechanizmy korekcji błędów, co czyni go bardziej wszechstronnym i niezawodnym w różnych zastosowaniach.

Czy kody kreskowe 2D mogą poprawić bezpieczeństwo zarządzania danymi?

Tak, kody kreskowe 2D mogą poprawić bezpieczeństwo zarządzania danymi poprzez kodowanie danych w zwartej i zaszyfrowanej formie, co utrudnia ich manipulowanie. Ta cecha sprawia, że idealnie nadają się one do bezpiecznych aplikacji, obsługiwanych przez biblioteki takie jak IronBarcode.

Jordi Bardia
Inżynier oprogramowania
Jordi jest najbardziej biegły w Pythonie, C# i C++. Kiedy nie wykorzystuje swoich umiejętności w Iron Software, programuje gry. Dzieląc odpowiedzialność za testowanie produktów, rozwój produktów i badania, Jordi wnosi ogromną wartość do ciągłej poprawy produktów. Różnorodne doświadczenia ...
Czytaj więcej

Zespol wsparcia Iron

Jestesmy online 24 godziny, 5 dni w tygodniu.
Czat
Email
Zadzwon do mnie