-
convert long to 4 bytes
Hello,
I have a Long (172,898) and need to convert it into four bytes.
The situation is this...I am creating a bit map and need to set the file length in the header. The length of the bitmap varies but it always has to fit into four bytes.
Thanks for any help...
- J
Here's how I did it in VB6 but now I need it in VB.NET:
Code:
'(My4Bytes is a data type defined in the module)
LSet My4Bytes = LengthOfFile_Long
tArray(3) = CByte(My4Bytes.b1)
tArray(4) = CByte(My4Bytes.b2)
tArray(5) = CByte(My4Bytes.b3)
tArray(6) = CByte(My4Bytes.b4)
-
More info:
If the length of the file is : 172,872
The Bytes would be: 48 a3 02 00
So if you take the bytes backwards they make the following DWord:2A348
Which equals exactly 172,872.
But how to automate this?
Thanks.
- J
-
I think I figured it out...
Hex()
-
You would probably want to look into the BitConverter class as well.