Skip to main content

Search

Search

Convert Hex-String To Binary Data

Comments

4 comments

  • Avatar
    Legacy Poster

    Nobody?

    0
  • Avatar
    Michael Toupin (mtoupin

    To work around this issue, change your script to:

     

    For y = 1 To Len(hextext)
          num = Mid(hextext, y, 2)
        if num = "00" then num = vbNull
        res = res & Chr(CByte("&h" & num))
          y = y + 1
    Next
     
     
    adding in the line "if num = "00" then num = vbNull" will convert the hex nul character to a vb based null character that the script editor can understand and pass into the barcode object.
    0
  • Avatar
    Legacy Poster

    It works! Awesome :) 

    Thank you very much!

    0
  • Avatar
    Ralf Gebhard

    bringing that thread out of the cellar....

    Above solution doesn't work because vbNull is represented as 0x01 (<SOH>) not 0x00 (<NUL>).
    The "Deutsche Post" uses binary Datamtarix ECC200.

    so lets see what happens with above code:

     if we have a hex data of "000000" eg. <NUL><NUL><NUL>  this will be converted to vbNull&vbNull&vbNull.

    and there's the failure: binary vbNull isn't 0x00 but 0x01.

    So if we have a decimal value to be converted in its hex and then binary/string equivalent:

    dec 100 -> hex 0064 -> string "<NUL>@" would be fine but the provided solution converts to
    dec 100 -> hex 0164 -> string "<SOH>@" back to decimal this is dec 356 !!!!

    I really tried a lot to render binary data in Datamatrix with Bartender, but failed with even ADODB streams, arrays, Access-Databases. It always fails when it comes to 0x00.

    Maybe anyone else has a solution for that.

    Ralf Gebhard

     

    0

Please sign in to leave a comment.