FAQ TBarCode OCX

Human Readable Text Is Not Rotated with Barcode

This occurs if the currently selected font does not support rotation. Select a TrueType font to solve the problem (e. g. Arial).

Change HRT Font in Microsoft Visual Basic, Visual C++, VBScript, PHP

Visual Basic

Dim fnt As stdole.StdFont
Set fnt = new stdole.StdFont
fnt.Name = "Arial"
Set TBC.Font = fnt

Microsoft Visual C++

COleFont cOF = m_TBarCode.GetFont();
tagCY cy = cOF.GetSize();
cOF.SetName("Arial"); // Font Family = Arial
cy.int64 = cy.int64 * 1.5; // add 50% to original size
cOF.SetSize(cy);
m_TBarCode.SetFont((LPDISPATCH) cOF);
cOF.ReleaseDispatch();

VBScript® (ASP):

Dim fnt
set fnt = Server.CreateObject("StdFont")
fnt.name = "Arial"
set TBC.Font = fnt

PHP (Windows):

$bcobj = new COM("TBarCode9.TBarCode9");
$fntobj = new COM("StdFont");
$fntobj->Name="Times";
$fntobj->Size=12;
$bcobj->Font=$fntobj;

How to Change the HRT Font in Navision / Dynamics NAV

You need to generate an Automation Variable of type OLE Automation.StdFont. This font object is then assigned to the TBarCode COM object.

Name      Data type       Subtype
StdFont   Automation    'OLE Automation'.StdFont
CLEAR(BC);
BC.Refresh;
IF ISCLEAR(StdFont) THEN
  CREATE(StdFont);
StdFont.Size := 30;
StdFont.Name := 'Arial';
BC.Font      := StdFont;

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

How Can I Create Mail Merge Documents with Barcodes in Word?

TBarCode Office

Create a mail merge document with a data source. Insert a barcode into the document. Use the button "Insert Merge Field" to insert a mail merge field (placeholder) into the barcode data.

TBarCode OCX

Version 9: For inserting multiple barcodes you can use the Serial Letter function in the TBarCode Word Toolbar. This function allows you to replace marked text with barcodes after the mail merge document was created. For more information about the TBarCode Toolbar and its functionality, please refer to the TBarCode OCX User Manual.

Version 10 / 11: If you encounter speed problems you may alternatively use the Word Mail Merge Macro which can be downloaded in the TBarCode Download Area. The required steps for using the macro are explained in the enclosed text document.

How to Add a Barcode Control Programmatically in Word VBA?

Sample code:

    Dim barcodeShape As InlineShape

    ' switch to design mode (optional)
    ' ActiveDocument.ToggleFormsDesign
    
    ' Insert barcode object at actual position in document
    Set barcodeShape = Selection.InlineShapes.AddOLEControl(ClassType:="TBarCode10.TBarCode10.1")

    ' change size
    barcodeShape.Width = 200
    barcodeShape.Height = 100

    ' adjust barcode properties programmatically
    barcodeShape.OLEFormat.Object.Barcode = 20    ' 20 = Code-128
    barcodeShape.OLEFormat.Object.Text = "Hello"
The “AddOLEControl“ function accepts a second parameter which can be a Range object where to place the Barcode Control.

I Am Unable to Protect My Word Documents

Since I've added TBarCode to my Word 2003 document, I cannot protect it.

Solution: You have to leave design mode to be able to protect the document. If you insert a Barcode Control, the document is switched to design mode. Through the Control Toolbox you can leave design mode, then you are able to protect the document.

Microsoft Excel - Licensing During Open

Licensing happens during startup of the document which contains the ActiveX® Control.

  • Open the Microsoft VBA editor with Alt+F11.
  • In the Project Explorer select This Workbook.
  • Now enter the following code as for the Workbook-Open Event (sample for TBarCode OCX V11):
  • Private Sub Workbook_Open()
     Dim tbc As TBarCode11
     Set tbc = CreateObject ("TBarCode11.TBarCode11")
     tbc.LicenseMe "Mem:Licensee", eLicKindDeveloper, 1, "Key", TBarCode11Lib.eLicProd1D
     Set tbc = Nothing
    End Sub

We recommend to password protect your VBA code in the project property window.

How Can I Setup ITF-14 via Excel VBA?

With the following code you can adjust ITF-14 with a bearer bar and a quiet zone.

Me.TBarCode111.BarCode = eBC_ITF14 
Me.TBarCode111.QuietZoneUnit = eMUModules 
Me.TBarCode111.QuietZoneLeft = 10
Me.TBarCode111.QuietZoneRight = 10 
Me.TBarCode111.BearerBarType = eBearerBar_TopAndBottom 

Me.TBarCode111.Text = "0123456789123" 
Or 
Me.TBarCode111.LinkedCell = "A1"

Get coordinates of cell:

With Selection
    X = .Cells(1, 1).Left
    Y = .Cells(1, 1).Top
    MsgBox "X = " < X < vbNewLine < "Y = " < Y
End With

Set the bar code position:

Me.TBarCode111.Left = X
Me.TBarCode111.Top = Y

Printing Through Excel VBA: Barcode Is Not Updated

You change the content of linked cells or the barcode control, then print directly from within VBA. But you see that the barcode controls still contain old values. The reason is that Excel does not send a redraw command to the ActiveX Controls before printing (if done from within VBA). This is a bug in Excel.

There is a workaround to force a redraw of the objects, you need to address each Barcode ActiveX Control programmatically in VBA and change its size before printing. Then it is redrawn by Excel.

'redraw a single barcode object by addressing it through its instance name

Dim origValue
origValue = TBarCode101.Width
TBarCode101.Width = origValue + 1
TBarCode101.Width = origValue
' redraw all ActiveX Controls on the current sheet

Sub UpdateOLEControls()
Dim myShape As shape
Dim counter As Integer
Dim origWidth As Single
For counter = 1 To ActiveSheet.Shapes.Count
  Set myShape = ActiveSheet.Shapes(counter)
  If (myShape.Type = msoOLEControlObject) Then
    ' resize => force redraw
    origWidth = myShape.Width
    myShape.Width = origWidth + 1
    myShape.Width = origWidth
  End If
Next counter
End Sub

Barcodes in Microsoft Access

The common method to print barcodes from within Microsoft® Access is by using a report. The TBarCode Object need only be inserted once at the report definition. Therefore you need a table (query) which servers as data source for the report and a data field, that specifies the content of the barcode.

How to insert TBarCode OCX (as ActiveX Control) in a report?

Open a new report in design view. If you need a barcode for each record, then insert the ActiveX® Control into the detail area and position it at the desired place.

Thereto you choose Insert - ActiveX Control in the main menu. You will see a list of all available elements, from which you select TBarCode.

The control will be inserted in the detail area. The detail area will be printed once for each record set in the table (or query).

How to control the content of the barcode in a report?

In design mode right-click the TBarCode - ActiveX® Control. You will see a menu where you select Properties.

In the field Control Source located in the sub menu data you can define the content of the control. That means you can select the table or query field which is encoded as barcode.

Truncated Barcodes in Microsoft Access

Depending on the printer driver the first bar in the symbol may be truncated (when printing through Microsoft Access). Also the symbol may be shifted inside of the bounding box.

If this occurs you can work around this problem by specifying an additional quiet zone around the barcode. This can be done in the property tab Appearance - Quietzone - Adjust.

If you have specified a module width, please make sure that the bounding box is large enough to display the barcode without clipping.

Microsoft Access - Licensing with Autoexec Macro

Below we show you how to license at startup of the database (sample for TBarCode OCX V11). Create a new Module with the following function (in Microsoft VBA Editor):

Public Function LicenseTBarCode()
 Dim TB As New TBarCode11
 TB.LicenseMe "Mem:Licensee", eLicKindDeveloper, 1, "Key", TBarCode11Lib.eLicProd1D
 Set TB = Nothing
End Function

Create a new Macro named "Autoexec" with the following settings:

Action = RunCode
Function Name = LicenseTBarCode()
Don't forget to include a reference to the type library of the ActiveX® Control in the menu Tools - References (otherwise enumerations cannot be used). We recommend to password protect your VBA code in the project property window.

How Can I Generate a PDF417 in Access VBA?

Please use this code snippet as starting point:

' set barcode type = PDF417
Me.bc.Object.BarCode = 55

' set size mode to CustomModuleWidth
Me.bc.Object.SizeMode = 1

' now adjust module width to 0.254 mms
Me.bc.Object.ModuleWidth = "254"

' set number of data columns
' optional parameter, but required to get constant width
Me.bc.Object.PDF417.Columns = 5

' adjust row height to 3 times of the module width
Me.bc.Object.PDF417.RowHeight = 254 * 3

Me.bc.Object.Text = "my data"

How Can I Calculate a Mod-10 Check Digit in Access VBA?

Please use this code snippet as starting point:

Public Function CalculateMod10(data As String) As String

Dim tbc As TBarCode11Lib.TBarCode11
Set tbc = CreateObject("TBarCode11.TBarCode11")
Dim cd As String
cd = tbc.CalculateCheckdigits(eCDMod10, data)
CalculateMod10 = Left(cd, 1)

End Function

Barcodes in Crystal Reports 8

It isn't possible to add TBarCode directly into a report, but you can create a barcode image “on the fly” and load it to a Picture Box. Follow the instructions below to see how embedding of TBarCode into Crystal Reports 8 works.

Embedding via Picture Box (VB6 sample)

In a form (named “Form1”) embed a TBarCode Control (named “tbc”) and a Picture Box (named “TmpPicture1”). Then add the function code below to the form. It creates a barcode image „on the fly“ and uses the PictureBox as drawing surface.

Public Function BarcodeGenerate(Id As String, Width As Long, Height As Long) As PictureBox
Dim nSizing, cm

    tbc.Text = Id
    cm = tbc.CountModules
    TmpPicture1.Cls
    TmpPicture1.ScaleMode = vbPixels
    Form1.ScaleMode = vbPixels

    Width = ScaleX(Width, vbTwips, vbPixels)
    Height = ScaleY(Height, vbTwips, vbPixels)
    nSizing = Int(Width / cm)
    If nSizing < 1 Then nSizing = 1

    TmpPicture1.Width = cm * nSizing
    TmpPicture1.Height = Height
    DoEvents
    tbc.BCDraw TmpPicture1.hDC, 0, 0, TmpPicture1.Width, TmpPicture1.Height
    Set BarcodeGenerate = TmpPicture1

End Function

In the Report event code (Format event) call the barcode generator function and assign the newly created barcode image to the Picture Box (named Picture1) in the report.

 Private Sub Section3_Format(ByVal pFormattingInfo As Object)
    'create the barcode for each record set
    Dim data As String
    data = Field1.Value
    Set Me.Picture1.FormattedPicture =
           Form1.BarcodeGenerate(data, Me.Picture1.Width, Me.Picture1.Height).Image
End Sub

Embedding via Bitmap File (VB6 sample)

In a form (named “Form1”) embed a TBarCode Control (named “TBarCode”) and adjust the barcode type and all other settings as desired. This barcode object will be used during report runtime for barcode creation “on the fly”.

In the Report event code (Format event) create a dynamic barcode image in a temp folder and load this image to the Picture Box (named pictBarCode) in the report.

 Private Sub Section3_Format(ByVal pFormattingInfo As Object)

' Simulate data binding
' by saving the barcode as bitmap with data from fldArticleID
' then reload it to a picture control

On Error Resume Next

Dim nWidth
Dim path
Dim fso
    
    ' here we use hard coded temp path (must exist!)
    path = "c:\temp\CR8_" & Me.fldArticleID.Value & ".bmp"
    
    ' reference the TBarCode Control in the Form1
    Form1.TBarCode.Text = Me.fldArticleID.Value
    Form1.TBarCode.PrintDataText = False
    nWidth = Form1.TBarCode.CountModules * 3 'adapt width to number of graphical modules
    
    Form1.TBarCode.SaveImage path, eIMBmp, nWidth, 100, 96, 96
    Me.pictBarcode.SetOleLocation (path)

End Sub

If you don’t want to add a barcode control on the form you can create an instance of TBarCode also in memory and apply the settings programmatically.

In newer Crystal Reports versions you can load the barcode image from an URL. For this method, check out the barcode service (samples folder), which is installed with TBarCode SDK.

Why Should I Use TBarCode Instead of a Barcode Font?

Adjustable PropertyTBarCodeBarcode Font
Module Widthyes*no
Print Ratiofreely scalablemaintain a special height / width ratio
Rotation 0°, 90°, 180°, 270°yesnot always

* Fine tuning of the bar width gives you better barcode quality results

How Can I Create an Optimal Bitmap for 203 DPI in VB6?

The sample code below uses a pre-set (custom) module width, sets the DPI and then calculates the total width of the symbol. The principle works for other printers, too.

The OCX method BCWidthHdc2 can be used to calculate the width of the barcode. If a module width has been set, use a dummy value for the [in] nWidth. If you calculate the width in unit=mm, convert it to Pixels for the SaveImage function. If you create a 2D code, use the BCHeightHd2 function for the height.

Sample Code:
Dim widthPx As Long
Dim heightPx As Long
Dim heightMM As Double
TBarCode111.Dpi = 203
TBarCode111.SizeMode = eSizeMode_CustomModuleWidth  ' =1
TBarCode111.ModuleWidth = "250"
heightPx = 100
heightMM = heightPx * (25.4 / TBarCode111.Dpi)
widthPx = TBarCode111.BCWidthHdc2(0, 1000, heightMM * 1000, eMUPixel)
TBarCode111.SaveImage "c:\temp\test.bmp", eIMBmp, widthPx, heightPx, 203, 203
A module width of 0.250 mm corresponds to 2 printer pixels at 203 dpi resulting in an optimal quality. Always use an integer multiple of 1 Pixel (0.12512 mm)

How Can I Create an Optimal Barcode Bitmap (1D Code) for 812.8 DPI in VB6?

Approach 1

The first approach uses a pre-set (custom) module width, sets the DPI and then calculates the total width of the symbol. The principle works for other printers, too.

The OCX method BCWidthHdc2 can be used to calculate the width of the barcode. If a module width has been set, use a dummy value for the [in] nWidth. If you calculate the width in unit=mm, convert it to Pixels afterwards for the SaveImage function. There is a similar function for the height – but the height needs calculation only for 2D barcodes.

Note: When you set a module width of exactly 0.3125mms or 0.0123 inches you are 100% in the printing raster of a 812.8 dpi machine. This is one of the recommended values. If you have enabled the opt resolution flag, the module width is changed to the next (lower) pixel boundaries in the printing raster and therefore “optimized”. Dpi must be set accordingly for this optimization.

Sample Code:
Dim widthPx As Long
Dim heightPx As Long
Dim heightMM As Double

TBarCode111.Dpi = 812.8
TBarCode111.SizeMode = eSizeMode_CustomModuleWidth
TBarCode111.ModuleWidth = "312.5"

heightPx = 500
heightMM = heightPx * (25.4 / TBarCode111.Dpi)
widthPx = TBarCode111.BCWidthHdc2(0, 1000, heightMM * 1000, eMUPixel)

TBarCode111.SaveImage "c:\temp\test2.tif", eIMTif, widthPx, heightPx, 812.8, 812.8

Approach 2

With the second, more simple approach, the module width is not set explicitly. Instead the scaling factor passed on to the GetOptimalBitmapSize (OCX API) function controls the module width. If you use it, don’t set a custom module width and/or optimal resolution in the API. This function performs some additional scaling (based upon dpi), which should be turned off with DPI = 0 before calling the function.

Because we know the DPI of the printer we also know the pixel (printer dot) dimension. We also know that one module should be always an integer multiple of one printer dot. We have to consider that typically one module should not be smaller than 0.190mms at all (but depends on barcode type). Then all you need to do is to pass on the ScaleX = ModuleWidth/PixelSize factor (= 8, 9, 10,…) to the GetOptimalBitmapSize function and use the returned values for SaveImage.

Module width: The 0.0123 inch optimum are 10 Pixels at 812.8 dpi. So the scaling factor would be 10 for the GetOptimalBitmapSize function.

Sample Code:
Dim width As Long
Dim height As Long
width = 1
height = 500
TBarCode111.Dpi = 0  'turn off additional dpi/96 scaling
TBarCode111.GetOptimalBitmapSize 10, 10, width, height
TBarCode111.SaveImage "c:\temp\test.tif", eIMTif, width, height, 812.8, 812.8

How Can I Generate an Optimized PDF417 Bitmap Image?

Please use this code snippet as starting point:

Barcode.Barcode = eBC_PDF417
Barcode.Text = "My Data... "

' the following settings produce a barcode 82,296 mm wide
' if your barcode should have a constant width, set the data columns
' as shown below (increase/decrease to make wider/smaller symbol)

Barcode.PDF417.Columns = 15

Dim X, Y
Dim Scaling
Dim Dpi

' define ratio of module width (small bar width) to row height
X = 1
Y = 1       ' keeps default ratio, which is 1:3
'Y = 3 / 2  ' creates 1:5 ratio

Dpi = 300     ' 300 dpi printer
Scaling = 3   ' 1 Module (smallest bar) = 3 Pixels = 0.254mm

Dim Cols
Dim Rows

Cols = Barcode.Get2DXCols()
Rows = Barcode.Get2DXRows()

Dim XSize
Dim YSize

XSize = Int(X * Cols)     
YSize = Int(Y * Rows)   

' scale with DPI enlarging factor
XSize = XSize * Scaling
YSize = YSize * Scaling

' Save barcode as bitmap
Barcode.SaveImage "c:\temp\barcode.bmp", eIMBmp, XSize, YSize, Dpi, Dpi

How to Encode Hexadecimal Sequences As Binary Values?

TBarCode V8-V9

For encoding Hex values with TBarCode V9 you have to use "Escape Sequences" in the format "\xhh" (hh=Hex value). It is necessary to convert the hex sequence (e.g. from DP Premiumadress) into this format and turn on the TBarCode property "EscapeSequences". Below we provide VBA sample code for this conversion:

' CreateTBCHEXString(sHexValue)
' sHexValue .... Converted data stream
' sets "\x" before each byte

Private Function CreateTBCHEXString(sHexValue)
    Dim sTBCText As String
   
    'set the prefix needed by TBarCode "\xhh"
    sHexPrefix = "\x"
    
    'bring the generated string into "\xhh" format
    For i = 1 To Len(sHexValue) Step 2
        sTBCText = sTBCText & sHexPrefix & Mid$(sHexValue, i, 2)
    Next i
    
    CreateTBCHEXString = sTBCText
End Function

TBarCode V10+

Instead of using escape sequences you can use the encoding mode Hexadecimal.


How to Encode Binary Data (2D Codes)

Even if you use an escape sequence for binary data the encoder will use code page conversion (example: \x88 leads to a different value in Data Matrix as desired).

Solution:

  • Switch off code page conversion (use encoding mode LowByte)
  • Force binary encoding mode if available (see PDF417 encoding mode, Data Matrix EnforceBinaryEncoding)
Relevant for DP Premium Address and other applications where you encode binary data in a 2D symbol (Data Matrix etc).

How to Generate an EAN / GS1 DataMatrix?

  • Adjust Data Matrix as symbology. In newer TBarCode versions you can also select GS1 Data Matrix as separate bar code type.
  • Set the Data Matrix format parameter to EAN ( enumeration eDMPr_UCCEAN). This inserts an FNC1 on the first position in the barcode and marks the barcode as GS1/EAN type.
  • Enable Escape Sequences
  • Use the sequence \F to encode an FNC1 separator character between variable length AIs.

How to Encode FNC1 in a GS1 Barcode?

To add the functional character FNC1 to your barcode data follow these steps:

  1. Enter the sequence \F to your bar code data where you need the FNC1.
  2. Make sure Escape Sequences are enabled in the barcode settings.
  3. FNC1 will be insert and the Application Identifier is recognized automatically in the HRT.

What's FNC1?

FNC1 is used as separator character for variable length data fields in the GS1 Application Identifier standard. It can be encoded with \F. Sample: The data field for the batch / lot number varies in length (up to 20 characters) and needs a termination (FNC1).

Please consider:

  • To encode FNC1 Escape-Sequences must be enabled.
  • Don't insert FNC1 after the last data field.
  • Insert FNC1 even if the maximum field length is used.

Example 1: FNC1 in TBarCode

In this example we generate a GS1-128 barcode with 2 Application Identifier. The batch or lot number (AI =10, variable length so it needs FNC1) and the best before date (AI=15).

' set the barcode type = GS1-128 (EAN/UCC 128)
TBarCode11.BarCode = eBC_GS1_128

' enable Translate Escape Sequences
TBarCode11.EscapeSequences = True

' set the data to be encoded
TBarCode11.Text = "10222333\F15100701"

Example 2: FNC1 in Barcode Studio

To add the functional character FNC1 to your barcode data follow these steps:

  • Enter the barcode data „10222333\F15100701“ .
  • Switch to the tab "Settings" and check Escape Sequences.
  • FNC1 will be insert and the Application Identifier (AI=15) is recognized automatically in the HRT.
  • In Barcode Studio 11.5+ you can use the new Assistant for GS1 Application Identifiers.

How Can I Create a vCard Barcode?

vCard is a special file format, which can be used to store personal data in a bar code (e.g. into QR Code®). Note that vCard is not a bar code type, it denotes only the data structure. A detailed description of the vCard format can be found on Wikipedia - vCard Specification.

Just bring your data into the given format and you'll be able to read the barcode with your mobile phone and recognize the data as contact information.

Create vCard Barcodes with Barcode Studio

In our vCard Video Tutorial we show you how to create vCard bar codes the easy way.

Special Characters (Umlauts)

For special characters you need to set the code page to UTF-8 and use vCard format 3.0 (vCard 2.1 also supports special characters, but not all apps evaluate this older format correctly).

Here is a sample vCard string:

BEGIN:VCARD
VERSION:3.0
N:Mustermann;Erika;;Dr.;
FN:Dr. Erika Mustermann
ORG:Wikimedia
ROLE:Kommunikation
TITLE:Redaktion  & Gestaltung
PHOTO;JPEG:http://commons.wikimedia.org/wiki/File:Erika_Mustermann_2010.jpg
TEL;WORK;VOICE:(0221) 9999123
TEL;HOME;VOICE:(0221) 1234567
ADR;HOME:;;Heidestrasse 17;Koeln;;51147;Deutschland
EMAIL;PREF;INTERNET:erika@mustermann.de
REV:20140301T221110Z
END:VCARD

QR Code® Character Set

QR Code was originally developed for Japanese barcode applications. The encodable character set consists of:

SHIFT JIS / CP932 contains both of these character sets and is the multibyte character set used by TBarCode for the older QR-Code implementation.

The later adopted QR Code standards changed the default encoding to Latin-1 - see next section.

QR-Code 2005 / QR-Code (ISO/IEC 18004:2015)

The newer ISO/IEC 18004:2006 and ISO/IEC 18004:2015 standards define ISO-8859-1 (Latin-1) as default character set. So the “old” QR-Code uses Shift-JIS and the "new" QR-Code uses Latin-1 as default character set.

Encoding special Latin-1 characters

Encoding the full Latin-1 character set with QR-Code 1997/2000 can lead to problems – for details see Barcode Reference (section Encoding Special Latin-1 Characters).

See also FAQ: Encoding Kanji Characters in QR Code Compaction Mode.

I Can't Encode Korean (or UTF-8) in a QR Code

QR Code was developed in Japan by Denso (for Toyota) and uses ASCII + Japanese (Kanji) as default character set. Later this has been changed by ISO to Latin-1. So your barcode reader tries to decode data in a QR Code either with the JIS X 0208 / JIS X 0201 or with the Latin-1 character set. Unless it is a barcode reader app or a special software decoder it does not look for UTF-8 or other character sets (except you use the ECI protocol)!

Possible solutions:

  • A keyboard wedge barcode reader may be configured to use UTF-8. Otherwise it will always use the default JIS or Latin-1 character set. The ECI protocol would allow different character sets but the reader must support this protocol.
  • A serial barcode reader (attached to COM Port or Virtual COM Port driver through USB) transmits the data as sequence of Bytes. The data processing software can decode the data stream and decide how to decode it - as JIS, Latin-1, UTF-8 or as Korean MB character set.
  • If your barcode reader supports Korean (or you use a serial barcode reader) you also can try to set the TBarCode code page property to Korean instead of UTF-8.
  • Smartphone reader apps by default try to decode QR codes with UTF-8. So chances are high that it works with a smartphone reader and codepage=UTF-8 adjusted in TBarCode.

How Can I Adjust the Default Barcode Type?

The default barcode type can be set through a file named barcode.ini.

The barcode.ini file must be located in the installation path of TBarCode and has to contain the following lines:

[DEFAULT_SETTINGS]
BarcodeType=8

The index (in this example 8) for the required barcode type can be found in the Barcode Reference, chapter 6.

Distorted Barcode Output, Black Bar at the Top

If this occurs during printing, this effect is caused by the printer driver. Along other printer models this effect happens with Toshiba TEC and DataMax printers.

If this occurs during bitmap generation, this effect is caused by the screen driver.

The solution is to change the draw mode of TBarCode:

TBarCode V8+

Set the ActiveX Property DrawMode to Compatible.

TBarCode V7

  1. Create a file barcode.ini with the following content:
  2. [DRAW_MODE]
    UseGDIRect=1
  3. Copy the barcode.ini file to the installation directory of TBarCode (where you can find the file tbarcode7.ocx or tbarcode7.dll).
  4. Restart the program.

VB Runtime Error '429': ActiveX Component Can't Create Object

You may get this runtime error if you didn't specify the full Prog-ID with CreateObject. Reference the TBarCode Type Lib in the project settings, and use the following commands to create a TBarCode object in VB (sample for TBarCode OCX V9):

      Dim objTB As TBarCode9
      Set objTB = CreateObject("TBarCode9.TBarCode9")
      objTB.AboutBox

For further trouble shooting read Microsoft Knowledge Base Article - 244264

Access Violation in MSVCR90.dll

The problem may occur with V10 on Windows 10 (version 1803 or later).

The ActiveX Control in V10 is based upon Visual Studio 2008 SP1 ATL templates. Since Windows 10 version 1803 we have seen stability problems connected to Office applications - it seems there was a change regarding ActiveX handling and/or container events. Please note that the official support for the Visual Studio 2008 Runtime by Microsoft ended in April 10, 2018.

Suggested Solution

The stability problems do not occur in TBarCode SDK V11.8+, which is based upon the newer Microsoft Visual C++ 2015 (Update 3) Runtime. We recommend to update the ActiveX Control to V11, which may require also a license update. Updates are free of charge if you own a priority support agreement.

Workaround

If you don't want to update to TBarCode SDK V11 for now (or you need a temporary solution) - you could try to run your application in a compatibility mode for a previous Windows version like shown here. We have seen that this helps in about 90% of the cases.

If you later want to remove the app from running in compatibility mode, you need to look for the corresponding registry key in HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers (and delete the key + restart the app).

Barcode Settings Lost After Reopening Document

Important note for Microsoft Office users: After performing the Microsoft security update from June 9, 2010 barcode objects embedded in Word and Excel documents (TBarCode OCX) may lose their settings:

Security Update for Microsoft Office Word 2003 (KB982134) + Word 2007 (KB982135)
Security Update for Microsoft Office Word 2003 (KB2251399) + Word 2007 (KB2251419)

TBarCode OCX loses barcode settings when opening or saving documents in Word 97-2003 format. Note: The problem does not appear with Word 2007 format (*.DOCX).

Security Update for Microsoft Office Excel 2003 (KB982133) + Excel 2007 (KB982308)

After opening or saving Excel files in Excel 97-2003 format, TBarCode OCX can no longer be edited or programmed. Note: The problem does not appear with Excel 2007 format (*.XLSX).

Microsoft Access is not affected by this problem, further Office 2003 or 2007 programs can be impaired (details see MS 10-036).

Workaround

As intermediate workaround (to gain time in production critical applications) you can uninstall the above listed security updates (see KB numbers) at your own risk.

Remedies:

  • TBarCode V9 users should update to TBarCode SDK V9.3.7 immediately: Update free of charge - download here. After updating please verify your barcodes and save the document!
  • Users of Microsoft Office 2007 (Word, Excel) may want to update to TBarCode Office V10.1 (download here).
  • Users of previous versions of TBarCode should update to TBarCode SDK V9.3.7 or alternatively to the upcoming version TBarCode SDK V10 (release in short, pre-release on request).

In case of update questions or for technical information please contact us.

VB Crashes When Reopening a Project with TBarCode OCX

When reopening a project with an embedded TBarCode element (on a form), Visual Basic crashes or shows an error message. This problem is caused by a problem in the Active Template Library (details here).

Use the following workaround (VB5, VB6) to solve this issue:

  • Insert the barcode control
  • Deactivate the control by adjusting the property (“Enabled” = False)
  • Save the project and open it – no crash
  • During runtime in the Form Load event set the Enabled property to True (programmatically)

    Private Sub Form_Load()
      TBarCode111.Enabled = True
    End Sub

TBarCode V9 Word Plug-In Not Visible in Word 2007

The following workaround can help to solve the problem with the disappearing toolbar (TBarCode V9!) in Word 2007:

  • Close Word 2007.
  • Rename or delete the following file:
  • File: "TBarCode Add-In.dot"
    Path (Windows XP): C:\Documents and Settings\[YourUserName]\Local
    Settings\Application Data\TEC-IT\TBarCode9 
    Path (Windows Vista): C:\users\[YourUserName]\AppData\Local\TEC-IT\TBarCode9
  • Start Word 2007.

By doing so, a new .DOT file should be created and the plug-in should be visible again.

For exploring application data you may have to enable "Show hidden files and folders" in Windows Explorer folder options.