Daily Archives: November 28, 2020

VB.NET || How To Generate, Create & Read A QR Code Using VB.NET

The following is a module with functions which demonstrates how to generate, create and read a QR code using VB.NET.

The functions demonstrated on this page has the ability to create and encode a string to a QR code byte array, and another function to read and decode a byte array QR code to a string.

The following functions use ZXing.Net to create and read QR codes.

Note: To use the functions in this module, make sure you have the ‘ZXing.Net‘ package installed in your project.

One way to do this is, in your Solution Explorer (where all the files are shown with your project), right click the ‘References‘ folder, click ‘Manage NuGet Packages….‘, then type ‘ZXing.Net‘ in the search box, and install the package titled ZXing.Net in the results Tab.


1. Create QR Code – Encode

The example below demonstrates the use of ‘Utils.CreateQRCode‘ to create a QR code byte array from string data.

The optional function parameters allows you to specify the QR code height, width and margin.


2. Read QR Code – Decode

The example below demonstrates the use of ‘Utils.ReadQRCode‘ to read a QR code byte array and decode its contents to a string.


3. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


4. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.