J
John Dann
I'm trying to generate a 4-byte unsigned integer in VB2005 that
encodes a number of bit-level variables. What I need to do is to be
able to compute a value for the uint that is based on specific values
for the constituent variables; the unit can then be passed to an
external DLL, which requires a function parameter in this form.
Unfortunately the only documentation I have for the external DLL is in
(I think) C++, which I'm struggling to understand. The C++ code for
the procedure to create a value for the number is:
MakeNumber(CV, DU, DT, ST, SID)
( ((CV) & 0x1F) | (((DU) & 0x1F)<<5) | (((DT) & 0x1F)<<10) |
(((ST) & 0xFF)<<16) | (((SID) & 0xFF)<<24) )
(The 3 lines above are all on a single line in the original code.)
So, the procedure is encoding values for the 5 variables CV, DU, DT,
ST, SID) in assembling the final uint.
Now I can see the gist of what's being done here and can spot the
bitwise operators but I've got 2 questions about how to translate this
procedure into VB2005:
1. Is there some equivalent assembly procedure that I can use in
VB2005 and if so what would the exact syntax be? For example is there
any equivalent of what seems to be the | operator?
2. What data type should I use for the values held in CV, DU etc?
UShort maybe?
Many thanks for any help.
encodes a number of bit-level variables. What I need to do is to be
able to compute a value for the uint that is based on specific values
for the constituent variables; the unit can then be passed to an
external DLL, which requires a function parameter in this form.
Unfortunately the only documentation I have for the external DLL is in
(I think) C++, which I'm struggling to understand. The C++ code for
the procedure to create a value for the number is:
MakeNumber(CV, DU, DT, ST, SID)
( ((CV) & 0x1F) | (((DU) & 0x1F)<<5) | (((DT) & 0x1F)<<10) |
(((ST) & 0xFF)<<16) | (((SID) & 0xFF)<<24) )
(The 3 lines above are all on a single line in the original code.)
So, the procedure is encoding values for the 5 variables CV, DU, DT,
ST, SID) in assembling the final uint.
Now I can see the gist of what's being done here and can spot the
bitwise operators but I've got 2 questions about how to translate this
procedure into VB2005:
1. Is there some equivalent assembly procedure that I can use in
VB2005 and if so what would the exact syntax be? For example is there
any equivalent of what seems to be the | operator?
2. What data type should I use for the values held in CV, DU etc?
UShort maybe?
Many thanks for any help.