|
-
Sep 8th, 2003, 04:24 PM
#1
Thread Starter
Addicted Member
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)
-
Sep 8th, 2003, 04:37 PM
#2
Thread Starter
Addicted Member
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
-
Sep 8th, 2003, 04:47 PM
#3
Thread Starter
Addicted Member
I think I figured it out...
Hex()
-
Sep 9th, 2003, 10:55 AM
#4
I wonder how many charact
You would probably want to look into the BitConverter class as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|