No, Marc,
"Binary coded decimal" is a well-known term (short term is BCD).

In it, each nibble (that's the two 4 bit parts of a byte) contains a
value between 0 and 9, which is read as a decimal digit.

Example: If you have the bytes &H12, &H34 and read them as BCD, their
value is 1234 (decimal)

Hence, to convert 3 bytes from BCD to a Integer value, do something like this:

Let's assum the string "bcdVal" contains the 3 bytes read from the
file or wherever. Then:

dim hexStr as String
hexStr = Right("0"+Hex(AscB(MidB(bcdVal1,1))),2) + _
  Right("0"+Hex(AscB(MidB(bcdVal2,1))),2) + _
  Right("0"+Hex(AscB(MidB(bcdVal3,1))),2) + _

Now the hexStr should contain 6 characters, such as "123456"
then simply convert this hexStr to an Integer using Val and you got
your decimal value.

Thomas

On 3/17/06, Aliacta <[EMAIL PROTECTED]> wrote:
> I'm afraid you'll have to find out what exactly the author meant with
> "binary-coded" i.e. how did he code it?
>
> Marc
>
> >I'm using a structure to read some data from a binary file, having
> >the record format of the data inside the file.
> >
> >all is working fine for text data, but on the record format I have:
> >
> >  chars 10 to 12  - date (day/month/year, expressed as a binary-coded
> >decimal number)
> >
> >I'm using a text field on the structure to read this, because only
> >reading as a string I can specify the number of chars to read,
> >but I'm quite confused about trasforming this chunk of binary data
> >in an integer.
> >
> >thank you,
> >
> >       Giulio
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to