FAQ TBarCode OCX
How Can I Add Additional Text Lines to the Control?
How Can I Add Additional Text Lines to the Control?
This is possible by changing the active text index programmatically. Below is an example for Excel VBA. TBarCode111 is the name of the TBarCode instance on the sheet.
' first add a quiet zone for our text area TBarCode111.QuietZoneTop = 10 TBarCode111.QuietZoneUnit = eMUMM ' set barcode data (+ normal HRT) in text area #0 TBarCode111.ActiveTextIndex = 0 TBarCode111.BarCode = eBC_Code128 TBarCode111.Text = "1234567890" TBarCode111.DisplayText = "" Dim fontBarcode As New stdole.StdFont fontBarcode.Name = "Arial" fontBarcode.Size = 12 TBarCode111.font = fontBarcode ' change text index to (auxiliary) text area #1 TBarCode111.ActiveTextIndex = 1 ' now adjust all settings for text area #1 TBarCode111.DisplayText = "My Label Text" TBarCode111.TextPositionLeft = 0 TBarCode111.TextPositionTop = 0 TBarCode111.TextClipping = False TBarCode111.PrintDataText = True Dim fontLabel As New stdole.StdFont fontLabel.Name = "Arial" fontLabel.Size = 10 fontLabel.Weight = 800 TBarCode111.font = fontLabel ' reset text index back to barcode text TBarCode111.ActiveTextIndex = 0
QR Code® with Text Label
Below is an example for creating a QR code using Excel VBA.
Dim BarcodeImageWidth As Long Dim BarcodeImageHeight As Long Dim BarcodeImageDPI Dim ImageScaling BarcodeImageDPI = 300 ImageScaling = 3 With bcTBarCode111 .BarCode = eBC_QRCode .QRCode.ECLevel = eQREC_Medium .Quality = 100 .SuppressErrorMsg = False .ActiveTextIndex = 0 .Text = "SERIAL00001" .QuietZoneBottom = 6 .QuietZoneLeft = 2 .QuietZoneRight = 2 .QuietZoneUnit = eMUModules .Dpi = BarcodeImageDPI End With bcTBarCode111.GetOptimalBitmapSize ImageScaling, ImageScaling, BarcodeImageWidth, BarcodeImageHeight Dim fontBarcodeLabel As New stdole.StdFont fontBarcodeLabel.Name = "Arial" fontBarcodeLabel.Size = 8 fontBarcodeLabel.Weight = 800 Dim PixelPerModule Dim CountVerticalModules CountVerticalModules = bcTBarCode111.Get2DXRows() + bcTBarCode111.QuietZoneBottom PixelPerModule = BarcodeImageHeight / CountVerticalModules With bcTBarCode111 ' change text index to (auxiliary) text area #1 .ActiveTextIndex = 1 ' now adjust all settings for text area #1 .DisplayText = .Text .TextPositionLeft = BarcodeImageWidth / 2 .TextPositionTop = BarcodeImageHeight - (PixelPerModule * (.QuietZoneBottom - 1)) .TextAlignment = eAlCenter .TextClipping = False .PrintDataText = True .Font = fontBarcodeLabel ' reset text index back to barcode text .ActiveTextIndex = 0 End With bcTBarCode111.SaveImage sFileName:="C:\Temp\SERIAL 00001.png", eImageType:=eIMPng, _ nXSize:=BarcodeImageWidth, nYSize:=BarcodeImageHeight, _ dXRes:=BarcodeImageDPI, dYRes:=BarcodeImageDPI