BCD conversation

BCD conversation

Hi,
I have to convert BCD numbers to integer or to double.
I've writen the code. It works, but it's very slow.
16 conversation takes more hthen 1 minute.
1. Why is it too slow?
2. How can I make the conversation?
3. Any other solution?
the present code:
Dim x0, x1, x2, x3, x4, x5, x6, x7 As Integer
Dim BCD_f, BCD_a As Variant

BCD_f = obProject.Variables.Item("9533_FW_OSSZ_M3_BCD_F").Value
x3 = BCD_f And 61440
x2 = BCD_f And 3840
x1 = BCD_f And 240
x0 = BCD_f And 15
BCD_a = obProject.Variables.Item("9534_FW_OSSZ_M3_BCD_A").Value
x7 = BCD_a And 61440
x6 = BCD_a And 3840
x5 = BCD_a And 240
x4 = BCD_a And 15
x4 = x4
x5 = (x5 / 16) * 10
x6 = (x6 / 256) * 100
x7 = (x7 / 4096) * 1000
x0 = x0 * 10000
x1 = (x1 / 16) * 100000
x2 = (x2 / 256) * 1000000
x3 = (x3 / 4096) * 10000000

obProject.Variables.Item("9533_D_OSSZ_M3").Value = x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7
Thank you
vpapp

This is a migrated post! Originally posted on 07.03.2012 by user markoszoft. Please be aware that information can be outdated.