FAQ TBarCode OCX
How to Encode Hexadecimal Sequences As Binary Values?
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.
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).