Windows Forms: How to Generate QR Code in VB.NET

This post shows you How to generate QR Code in VB.NET using ThoughtWorks.QRCode

Here's a simple example of how you can generate barcodes in VB.NET Windows Forms Application.

How to create a QR code in VB.NET

First, You can design a simple UI allows you to enter a number in textbox, then generate qr code image as show below.

generate qrcode in

We will use ThoughtWorks library to help generate qr code in

This example requires the ThoughtWorks.QRCode library, which you can install via NuGet Package Manager by right-clicking on your project, then select Manage Nuget Packages.


At the search box, search for "ThoughtWorks" and install it.

Next, Open your form designer, then double click on the Generate button

'qr code
Private Sub btnGenerate_Click(sender As Object, e As EventArgs) Handles btnGenerate.Click
    Dim qrEncoder As New QRCodeEncoder()

    ' Set QR code encoding mode to Numeric
    qrEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC

    ' Set QR code scale
    qrEncoder.QRCodeScale = 4

    ' Generate QR code image
    pic.Image = qrEncoder.Encode(txtBarcode.Text)
End Sub

This example generates a QR code for the data "1234567890" when the button is clicked and displays the QR code in a PictureBox control. You can easily customize the data you want to encode by changing the value at the textbox control.