Creating barcodes in ASP.NET/VB

Barcode in ASP.NET/VB

Table of Contents

This page shows how to create a barcode in ASP.NET using VB code and StrokeScribe barcode generator.

How to Proceed

The Code Example

This code creates a GIF image of QR Code. For other barcode types, see code snippets below.

<%@ Page Language="VB" Debug="true"%> <% dim barcode = CreateObject("STROKESCRIBE.StrokeScribeClass.1") barcode.Alphabet = 25 ' 25=QRCODE barcode.Text = "ABCDEF123" dim w = barcode.BitmapW dim h = barcode.BitmapH Dim arr() As Byte arr = barcode.GetPictureArray(1, w*5, h*5) ' 1=GIF if barcode.Error then Response.Write(barcode.ErrorDescription) return end if Response.Clear() Response.ClearHeaders() Response.ContentType = "image/GIF" Response.AddHeader("Content-Disposition", "attachment; filename=barcode.gif") Response.OutputStream.Write(arr, 0, UBound(arr)) %>

Some words about choosing the image's width/height:

Code Snippets by Barcode Type

CODE 128 barcode in ASP.NET + VB

CODE 128

To create a Code 128, modify your code in the following way:

barcode.Alphabet = 5 ' 5=CODE128 barcode.Text = "ABC" & chr(9) & "DEF" ' An example how to encode ASCII control characters dim w = barcode.BitmapW Dim arr() As Byte arr = barcode.GetPictureArray(1, w*2, w)

How to Specify an Alternative Text Below the Barcode

barcode.TextBelow = "Hello" QR CODE barcode in ASP.NET + VB

QR Code

To create a QR Code, modify your code in the following way:

barcode.Alphabet = 25 barcode.Text = "123ABCD"

How to Encode a Byte Array

barcode.Alphabet = 25 barcode.CodePage = -1 Dim b(0 To 2) As Byte b(0) = &H10 b(1) = &H20 b(2) = &H30 barcode.Text = b

Mobile-friendly Barcodes

Use UTF-8 encoding to make barcodes with national characters readable by mobile barcode readers.

barcode.Alphabet = 25 barcode.CodePage = 65001 ' 65001 = UTF-8 barcode.Text = "ΞΟΠΡΣΤΥΦ"

How to Modify the Error Correction Level

barcode.Alphabet = 25 barcode.QrECL = 0

How to Force the Minimum Matrix Size

barcode.Alphabet = 25 barcode.QrMinVersion = 11 PDF417 barcode in ASP.NET + VB

PDF417

To create a PDF417 barcode, modify your code in the following way:

barcode.Alphabet = 6 barcode.Text = "123ABC" dim w = barcode.BitmapW dim h = barcode.BitmapH Dim arr() As Byte arr = barcode.GetPictureArray(1, w, h)

To create a Compact PDF417:

barcode.Alphabet = 6 barcode.CompactPDF417 = True

How to Set the Non-default Error Correction Level

barcode.Alphabet = 6 barcode.PDF417ErrLevel = 8

How to Fix the Number of Rows or Columns

barcode.Alphabet = 6 barcode.PDF417Cols = 3 barcode.PDF417Rows = 7 Data Matrix barcode in ASP.NET + VB

DATA MATRIX

To create a Data Matrix barcode, modify your code in the following way:

barcode.Alphabet = 8 barcode.Text = "ABC123DEF"

How to Force the Minimum Matrix Size

barcode.DataMatrixMinSize = 132

How to Modify the Quiet Zone Size

barcode.QuietZone2D = 0
Facebook X Bluesky Youtube Contacts

© 2026 StrokeScribe. All rights reserved. Use of any portion of this site constitutes acceptance of our Terms of Use and Privacy Policy. The website material may not be reproduced, except with the prior written permission.