From: John Morley on
Hi All,

Is there a handy way to convert a decimal value to it's equivalent BCD
representation in VB?? I need to send some data to a controller that
expects date data in BCD. For example the month of October (decimal 10)
would be sent as "16" (BCD equivalent of 10).

Thanks!

John
From: Dave on
John

I think you should go and do some research into BCD.

The BCD for 10 is 2 bytes, one of 1 and one of 0.
In BCD is each decimal number expressed in binary so 1 to 12 is

1 0000 0001
2 0000 0010
3 0000 0011
4 0000 0100
5 0000 0101
6 0000 0110
7 0000 0111
8 0000 1000
9 0000 1001
10 0001 0000
11 0001 0001
12 0001 0010

Best Regards
Dave O.

"John Morley" <jmorley(a)nospamanalysistech.com> wrote in message
news:ugxYLKbzFHA.3000(a)TK2MSFTNGP12.phx.gbl...
> Hi All,
>
> Is there a handy way to convert a decimal value to it's equivalent BCD
> representation in VB?? I need to send some data to a controller that
> expects date data in BCD. For example the month of October (decimal 10)
> would be sent as "16" (BCD equivalent of 10).
>
> Thanks!
>
> John


From: Jim Mack on
John Morley wrote:
> Hi All,
>
> Is there a handy way to convert a decimal value to it's equivalent BCD
> representation in VB?? I need to send some data to a controller that
> expects date data in BCD. For example the month of October (decimal
> 10) would be sent as "16" (BCD equivalent of 10).
>

I was with you until you got to "16". I've never seen 10 decimal represented as 16 BCD. Since what you want isn't 'standard' BCD, maybe you could give us some more examples of decimal numbers represented in the way you need them, and we could work out the relationship.


--

Jim Mack
MicroDexterity Inc
www.microdexterity.com

From: Randy Birch on
The BCD of 10 is 0001 0000, not 16. Using your examples (10 >16) it
appears you are talking decimal>hex, ...

?&H10
16
?hex(16)
10

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------


"John Morley" <jmorley(a)nospamanalysistech.com> wrote in message
news:ugxYLKbzFHA.3000(a)TK2MSFTNGP12.phx.gbl...
: Hi All,
:
: Is there a handy way to convert a decimal value to it's equivalent BCD
: representation in VB?? I need to send some data to a controller that
: expects date data in BCD. For example the month of October (decimal 10)
: would be sent as "16" (BCD equivalent of 10).
:
: Thanks!
:
: John

From: John Morley on
Hi,

Hmmm, perhaps I didn't ask the right question? The value "10" is made up
of two digits "1" and "0". "1" is represented as 0001, and "0" is 0000.
Put together, this becomes 00010000 which is decimal 16. I need a
routine to make this conversion (10 --> 16).

Thanks,

John



Dave wrote:
> John
>
> I think you should go and do some research into BCD.
>
> The BCD for 10 is 2 bytes, one of 1 and one of 0.
> In BCD is each decimal number expressed in binary so 1 to 12 is
>
> 1 0000 0001
> 2 0000 0010
> 3 0000 0011
> 4 0000 0100
> 5 0000 0101
> 6 0000 0110
> 7 0000 0111
> 8 0000 1000
> 9 0000 1001
> 10 0001 0000
> 11 0001 0001
> 12 0001 0010
>
> Best Regards
> Dave O.
>
> "John Morley" <jmorley(a)nospamanalysistech.com> wrote in message
> news:ugxYLKbzFHA.3000(a)TK2MSFTNGP12.phx.gbl...
>
>>Hi All,
>>
>>Is there a handy way to convert a decimal value to it's equivalent BCD
>>representation in VB?? I need to send some data to a controller that
>>expects date data in BCD. For example the month of October (decimal 10)
>>would be sent as "16" (BCD equivalent of 10).
>>
>>Thanks!
>>
>>John
>
>
>
 |  Next  |  Last
Pages: 1 2 3 4
Prev: Transparent Picturebox
Next: Error from Hell: Overflow