Results 1 to 4 of 4

Thread: [RESOLVED] Bytes to long integer

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Resolved [RESOLVED] Bytes to long integer

    Hi, I'd like to get a certain value from an avi video, but I'm not really sure how to do this. Byte 4 - 7 contains the real size of an avi video. These 4 bytes need to be converted to a long integer (I think).

    In the example (screenshot):

    Byte 4 = EA
    Byte 5 = B9
    Byte 6 = 8C
    Byte 7 = 0E

    EA B9 8C 0E = 244103658 bytes (original file size).

    Does anybody know how to get Byte 4 - 7 and convert it, so I get the long integer value?

    Thanks.


  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Bytes to long integer

    Since a long integer is 4 bytes, just open the file and get them.

    VB Code:
    1. Dim lngFile as Long
    2. Dim lngSize as Long
    3.  
    4. lngFile = FreeFile
    5. Open FileName For Binary as #lngFile
    6. Get #lngFile, 4, lngSize
    7. Close #lngFile

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Bytes to long integer

    VB Code:
    1. Dim s1 As String * 2, s2 As String * 2, s3 As String * 2, s4 As String * 2, s As String, l As Long
    2.  
    3.   s1 = "0E"
    4.   s2 = "8C"
    5.   s3 = "B9"
    6.   s4 = "EA"
    7.   s = "&H" & s1 & s2 & s3 & s4
    8.   l = s 'l will equal 244103658
    I'll leave reading the bytes and stuffing them into the variables to you.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Bytes to long integer

    Thanks for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width