VB.NET QR Code Generator Introduction
QR Code, also known as Denso Barcode, QRCode, Quick Response Code, is a kind of 2D (two dimensional) barcode widely used today.
Using VB.NET QR Code Generator to create QR Code barcodes in VB.NET program is a simple and easy job. VB.NET QR Code Generator control is easy to install with a single .NET Barcode generation control. It is easy to generate QR Code barcodes in VB.NET class with detailed VB.NET QR Code settings document and complete demo for QR Code generation in VB.NET provided in this article.
QR Code Generators
OnBarcode provides several QR Code Generator components and software, including
QR Code Generator,
QR Code .NET,
QR Code Java,
QR Code C#,
QR Code in BIRT reports,
QR Code in RDLC reports,
QR Code in Crystal reports,
QR Code ASP.NET.
Quick to create, print QR Code in VB.NET class
It is an easy job to generate and print a QR Code in Visual Basic class using OnBarcode .NET Barcode Generator library.
- Create a
QRCodevb object - In property
Data, enter the QR Code encoding data text - Call method
drawBarcode()to create and print the QR Code to a PNG image file
Dim qrcode = New QRCode() qrcode.Data = "https://www.onbarcode.com" qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-demo.png")
QR Code Data Encoding in VB.NET
QR Code encoding character sets
QR Code supports encoding the following character sets:
- Numbers (digits 0-9)
- ASCII characters. standard 128 ASCII chars and extended chars
- Unicode text
- Binary data
- Kanji characters. Kanji characters in QR Code can be compacted into 13 bits.
QR Code Data Mode
To encode QR Code data efficiently, QR Code will choose one or more data modes to encode data text.
- QRCodeDataMode.Auto : The data modes will be automatically selected by VB.NET barcode library
- QRCodeDataMode.Numeric : For numbers (digits 0 - 9)
- QRCodeDataMode.AlphaNumeric : alphanumeric data (digits 0 - 9; upper case letters A -Z; nine other characters: space, $ % * + - . / : )
- QRCodeDataMode.Byte : byte data (default: ISO/IEC 8859-1; or other sets as otherwise defined)
- QRCodeDataMode.Kanjis : Kanji characters. Kanji characters in QR Code can be compacted into 13 bits.
qrcode.DataMode = QRCodeDataMode.Auto
QR Code maximum data size
Maximum data characters per QR Code symbol with QR Code Version (40) and error correction mode (L)
- numeric data: 7,089 characters
- alphanumeric data: 4,296 characters
- byte data: 2,953 characters
- Kanji data: 1,817 characters
QR Code Error Correction Mode (ECL)
QR Code ISO standard defines four levels of Reed-Solomon error correction (referred to as L, M, Q and H in increasing order of capacity). With ECL applied, you can
recover the QR Code data when partial data is damaged.
- L: 7% (default)
- M: 15%
- Q: 25%
- H: 30%
ECL.
qrcode.ECL = QRCodeECL.M
How to generate QR Code with complex text and data format in VB.NET?
Here we will explain how to encode QR Code with the following text formats in vb.net
- Full 128 ASCII characters (including printing and non-printing chars)
- Unicode text
- GS1 data message
- Binary data
Encode QR Code with ASCII characters
Full ASCII table characters include 128 chars, 95 printable characters and 33 control characters (non-printing chars).
You can enter the printable chars (such as digits, letters) in the
Data property. For non-printing chars, you need convert each char to it's ASCII int value in 3 digits string.
- Enable property
ProcessTildeto true - In property
Data, each non-printing char will be converted to it's ASCII int value in 3 digits with "~" char in the beginning
Dim qrcode = New QRCode() qrcode.Data = "ABC~013abc" qrcode.ProcessTilde = True qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-data-ascii.png")
Encode QR Code with Unicode text
- Enable property
EncodeUnicodeTextto true. Now you can create QR Code with unicode text encoded. - In property
Data, enter the Unicode text directly
Dim qrcode = New QRCode() qrcode.Data = "你好 in Chinese" qrcode.EncodeUnicodeText = True qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-data-unicode-text.png")
Create GS1 QR Code
- Set property
FNC1toFNC1.FNC1_1ST_POS. The vb.net barcode library will automatically insert theFNC1char in the first postion in QR Code encoding data, which represents the printed QR Code is GS1 compatible QR Code. - In property
Data, enter the GS1 business data message. Each AI code will be surrounded by "()"
Dim qrcode = New QRCode() qrcode.Data = "(17)050101(10)ABC123" qrcode.FNC1 = FNC1.FNC1_1ST_POS qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-data-gs1.png")
Encode QR Code with binary data
- Enable property
ProcessTildeto true - In property
Data, each byte data will be converted to it's int value in 3 digits with "~" char in the beginning - Set property
DataModetoQRCodeDataMode.Byte. Now the QR Code supports binary data encoding in vb.net class.
Dim message = "你好-hello-in-Chinese" Dim bytes = Encoding.UTF8.GetBytes(message) Dim bytesInSb = New StringBuilder() For Each b In bytes bytesInSb.Append("~" + b.ToString().PadLeft(3, "0")) Next Dim qrcode = New QRCode() qrcode.Data = bytesInSb.ToString() qrcode.ProcessTilde = True qrcode.DataMode = QRCodeDataMode.Byte qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-data-binary.png")
QR Code Dimension Size in VB.NET
QR Code image width & height
- Customize QR Code width and height size through
BarcodeWidth. By default, the QR Code image width and height are the same.
Dim qrcode = New QRCode() qrcode.Data = "https://www.onbarcode.com" qrcode.BarcodeWidth = 250 qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-size-width-demo.png")
If you want to customize the QR Code bar module width (X) value, you need disable
AutoResize. It's default value is true.
- Disable property
AutoResizeto false - Set the QR Code image width in property
BarcodeWidth, image height in propertyBarcodeHeight - Customize the QR Code bar module size through property
X
Dim qrcode = New QRCode() qrcode.Data = "https://www.onbarcode.com" qrcode.AutoResize = False qrcode.BarcodeWidth = 250 qrcode.BarcodeHeight = 250 qrcode.X = 8 qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-size-module-x-demo.png")
QR Code Versions
The vb.net QR Code generator library will automatically choose the right QR Code version, according to the encoding data, error correction level configuration.
You can also manually decide the QR Code version through property
Version
Dim qrcode = New QRCode() qrcode.Data = "https://www.onbarcode.com" qrcode.BarcodeWidth = 250 qrcode.Version = QRCodeVersion.V5 qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-qrcode-version.png")
QR Code Quiet Zones
You can customize the rendered QR Code quiet zone (margins) value through the following properties.
Dim qrcode = New QRCode() qrcode.Data = "https://www.onbarcode.com" qrcode.BarcodeWidth = 250 qrcode.LeftMargin = 30 qrcode.RightMargin = 30 qrcode.TopMargin = 30 qrcode.BottomMargin = 30 qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-quiet-zones.png")
QR Code Color & Image Settings in VB.NET
VB.NET QR Code generator library supports bar and space module color customization and various raster and vector image format outputs.
You can view the details here:
How to print barcode with colors, image option settings in VB.NET?
How to print barcode with colors, image option settings in VB.NET?
Dim qrcode = New QRCode() qrcode.Data = "https://www.onbarcode.com" qrcode.ForeColor = Color.Red qrcode.BackColor = Color.White qrcode.OutputFileFormat = FileFormat.PNG qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-color-image.png")
How to print QR Code with logo image using VB.NET?
You can insert a logo image on the printed QR Code using VB.NET QR Code generator library.
- Set the property
Logowith the inserted logo image in Bitmap object - Customize the logo image displaying width and height through property
LogoActualSize - Set property
ECLtoQRCodeECL.M. Since part of the QR code is covered by the logo image, you need to set the error correction level (ECL) to prevent recognition failures by QR code scanners.
Dim qrcode = New QRCode() qrcode.Data = "https://www.facebook.com" qrcode.Logo = New Bitmap("C://Input//facebook.png") qrcode.LogoActualSize = New SizeF(90, 90) qrcode.ECL = QRCodeECL.M qrcode.drawBarcode("C://Output//vb-net-qr-code-how-to-logo.png")
Common Asked Questions
What does QR stand for in code?
QR stands for "quick response", and QR Code is a 2-dimensional matrix barcode on steroids. The QR code stores data information both horizontally and vertically.
OnBarcode VB.NET Barcode Generator library supports QR Code generation in Visual Basic .NET class library, console, WinForms, WPF windows applications.
What is the smallest size a QR Code can be printed?
If your QR Code will be scanned by QR Code scanner devices, the minimum size for a QR Code is 1 x 1 cm. However if the QR Code will be scanned by smartphones (iOS or Android),
most the barcode scanner app requires that the minimum size for a QR Code is 2 x 2 cm.
Using VB.NET QR Code Generator library, you can create and customize the printed QR Code dimension size through methods
Using VB.NET QR Code Generator library, you can create and customize the printed QR Code dimension size through methods
QRCode.setBarcodeWidth() in Visual Basic .NET class.
How to create a QR Code for a picture?
To create a QR code from a photo or an image in VB.NET project
- Convert the photo image raw data into byte array
- Create a
QR Codeobject - Set the QR Code data mode in method
setDataMode()withQRCode.M_BYTEas parameter - Set
setProcessTilde()with valuetrue - Set QR Code encoding data through method
setData() - Print and output QR Code to an image file
Does the color of a QR Code matter?
Choose whatever colors you want but always make sure the back and fore colors have strong contrast.
We suggest at least 70% darker to ensure reliable scanning, and always scan and verify your QR code to make sure it works using the colors you've chosen.
In VB.NET class, you can create and initiate a
In VB.NET class, you can create and initiate a
QRCode object to generate QR Code barcode images,
and customize the QR Code bar color through method setForeColor(),
and the QR Code background color through method setBackColor(), in VB.NET class QRCode
How much data can be stored in a QR code?
A standard QR Code can store up to three kilobytes (KB) of data. A QR Code symbol with version 40-L can hold the following data information:
- numeric data: 7,089 characters
- alphanumeric data: 4,296 characters
- byte data: 2,953 characters
- Kanji data: 1,817 characters
QRCode object to generate QR Code barcode images,
and set the encode the data through method setData().
What is the difference between a barcode and a QR Code?
Barcode is usually known as 1d or linear barcode symbology, which can store limited number of characters.
QR Code or Quick Response code, is a type of two-dimensional code that can hold more than 4,200 alphanumeric characters.
Using OnBarcode VB.NET Barcode Generator library, you can create QR Code (standard, GS1, Micro, Macro versions) and other 20+ 2d, 1d barcodes such as Code 128, Data Matrix, EAN/UPC barcodes in Visual Basic .NET class library, console, WinForms, WPF windows applications.
Using OnBarcode VB.NET Barcode Generator library, you can create QR Code (standard, GS1, Micro, Macro versions) and other 20+ 2d, 1d barcodes such as Code 128, Data Matrix, EAN/UPC barcodes in Visual Basic .NET class library, console, WinForms, WPF windows applications.