Barcode Data Encoding using VB.NET
Barcode data encode
The following VB.NET source codes show how to generate a Code 128 barcode image in VB.NET projects.
- Enter the barcode encoding text to property
Data
Dim barcode = New Linear() barcode.Data = "Code 128" barcode.Type = BarcodeType.CODE128 barcode.drawBarcode("C://Output//vb-net-barcode-how-to-demo.png")
Add-on data encode
EAN/UPC barcodes (including EAN-13, EAN-8, UPC-A, UPC-E, ISBN, ISSN) may contain 2-digit or 5-digit add-on code.
The following VB.NET codes explain how to create an EAN-13 with 2-digit add-on barcode in VB.NET class.
- Enter the barcode add-on digits to property
SupData
Dim barcode = New Linear() barcode.Type = BarcodeType.EAN13_2 barcode.Data = "123456789012" barcode.SupData = "12" barcode.drawBarcode("C://Output//vb-net-barcode-how-to-barcode-add-on-demo.png")
Barcode Advanced Data Encoding using VB.NET
Encode ASCII standard & extended characters
Most 128 ASCII characters and ASCII extended characters are printing characters. You can directly input them to property
Data using VB.NET barcode library.
- Enter ascii string to property
Data
Dim barcode = New Linear() barcode.Type = BarcodeType.CODE128 barcode.Data = "ASCII-123-abc" barcode.drawBarcode("C://Output//vb-net-barcode-how-to-data-ascii-chars-demo.png")
Encode ASCII non-printing characters
Some ASCII characters are non-printing chars. They are control characters, which cannot be input directly using keyboard.
Using VB.NET Barcode Generator library, for each non-printing characters, you need convert its ASCII integer value to 3-digit string by padding them on the left with "0" for a fixed 3-digit length. For example, the char 'carriage return' (or [CR]) ascii value is 13, you need convert it to "~013".
Note: the non-printing chars will be encoded in the bar code modules, but they will not be displayed in the barcode text.
Using VB.NET Barcode Generator library, for each non-printing characters, you need convert its ASCII integer value to 3-digit string by padding them on the left with "0" for a fixed 3-digit length. For example, the char 'carriage return' (or [CR]) ascii value is 13, you need convert it to "~013".
- Enable property
ProcessTildeto true. Now you can use "~" to represent each non-printable characters. - Set the barcode encoding data to property
Data, and each non-printing chars have been converted to "~" with 3-digits text.
Dim barcode = New Linear() barcode.Type = BarcodeType.CODE128 barcode.ProcessTilde = True barcode.Data = "ASCII-123~013abc" barcode.drawBarcode("C://Output//vb-net-barcode-how-to-data-ascii-non-printing-chars-demo.png")
Note: the non-printing chars will be encoded in the bar code modules, but they will not be displayed in the barcode text.
Encode Unicode text
Besides encoding ISO 8859-1 standard data, Onbarcode.com's VB.NET barcode encoder can also encode other data, such as Arabic, Cyrillic, Greek, Hebrew. And users can encode these special characters through the Unicode encoding function of our VB.NET Barcode Generator.
The following VB.NET codes are used to encode Unicode into two-dimensional barcode symbology QR Code, Data Matrix and PDF417. For more, you can input VB.NET code to change barcode height, color and other properties.
Please note that, the VB.NET barcode library will use UTF-8 encoding to convert Unicode text to 2d barcodes, such as QR Code.
Therefore, to scan and obtain original data,
you need to convert the decoded data back to original data via UTF-8 encoding. Most of the smart phone barcode scanner will decode QR Code and Data Matrix using UTF-8 by default.
- Enable property
EncodeUnicodeTextto true - Input the Unicode text to property
Data
Dim barcode = New QRCode() barcode.EncodeUnicodeText = True barcode.Data = "你好-hello-in-Chinese" barcode.drawBarcode("C://Output//vb-net-barcode-how-to-data-unicode-text-demo.png")
Encode binary data
Using VB.NET Barcode Generator library, for each byte data, you need convert its integer value to 3-digit string by padding them on the left with "0" for a fixed 3-digit length.
For example, the byte (32) will be converted to string "~032".
- Enable property
ProcessTildeto true. Now you can use "~" to represent each byte data. - In property
DataMode, set QR Code data mode to Byte - Set the barcode encoding data to property
Data, and each byte value will be converted to "~" with 3-digits text.
Dim barcode = New QRCode() Dim dataMessage = "你好-hello-in-Chinese" Dim bytes = Encoding.UTF8.GetBytes(dataMessage) Dim bytesInSb = New StringBuilder() For Each b In bytes bytesInSb.Append("~" + b.ToString().PadLeft(3, "0")) Next barcode.Data = bytesInSb.ToString() barcode.ProcessTilde = True barcode.DataMode = QRCodeDataMode.Byte barcode.drawBarcode("C://Output//vb-net-barcode-how-to-data-binary-demo.png")
Encode GS1 data message
VB.NET barcode encoding control owns the GS1-compatible data encoding function, so it can easily export & display these GS1 compatible barcode images encoding numbers with VB.NET scripting. Please install the barcode plugin by adding it to reference and toolbox first.
The following example text string will illustrate how to use VB.NET class codes to encrypt those GS1-compatible barcodes (GS1 DataBar, EAN-128/GS1-128, ITF-14, Data Matrix, and QR Code).
Default value is Png, while you can output image in Gif, Jpg, Tif via VB.NET.
Dim barcode = New Linear() barcode.Type = BarcodeType.EAN128 barcode.Data = "(00)395123451234567895(01)09501101530003" barcode.drawBarcode("C://Output//vb-net-barcode-how-to-data-gs1-demo.png")
To generate GS1 QR Code, you need set
FNC1 property with value FNC1.FNC1_1ST_POS
- Set property
FNC1to valueFNC1.FNC1_1ST_POS. - In property
DataMode, set QR Code data mode toQRCodeDataMode.Auto - Set the QR Code data with GS1 data message
Dim barcode = New QRCode barcode.FNC1 = FNC1.FNC1_1ST_POS barcode.DataMode = QRCodeDataMode.Auto barcode.Data = "(00)395123451234567895(01)09501101530003" barcode.drawBarcode("C://Output//vb-net-barcode-how-to-data-gs1-qrcode-demo.png")
VB.NET Barcode Generation Guide for Linear & 2D Barcode Types
.NET Barcode Component for VB.NET - Barcodes Generation
- VB.NET Linear Barcodes Generation:
- VB.NET 2D Barcodes Generation: Data Matrix, PDF417, QR Code, Micro PDF417, Micro QR Code
