Results 1 to 4 of 4

Thread: [RESOLVED] binary reading

  1. #1

    Thread Starter
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Resolved [RESOLVED] binary reading

    what is a fast way of reading binary?

    thnx in advance

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: binary reading

    Code:
    Bit 1: 1
    Bit 2: 2
    Bit 3: 4
    Bit 4: 8
    Bit 5: 16
    Bit 6: 32
    Bit 7: 64
    Bit 8: 128
    
    Hex 1 = 1
    Hex 2 = 2
    Hex 4 = 4
    Hex 8 = 8
    Hex 10 = 16
    Hex 20 = 32
    Hex 40 = 64
    Hex 80 = 128
    VB Code:
    1. Dim bytSample As Byte
    2. bytSample = 173
    3. Debug.Print "Number is " & bytSample
    4. Debug.Print "Bit 1 active: " & ((bytSample And &H1) = &H1)
    5. Debug.Print "Bit 2 active: " & ((bytSample And &H2) = &H2)
    6. Debug.Print "Bit 3 active: " & ((bytSample And &H4) = &H4)
    7. Debug.Print "Bit 4 active: " & ((bytSample And &H8) = &H8)
    8. Debug.Print "Bit 5 active: " & ((bytSample And &H10) = &H10)
    9. Debug.Print "Bit 6 active: " & ((bytSample And &H20) = &H20)
    10. Debug.Print "Bit 7 active: " & ((bytSample And &H40) = &H40)
    11. Debug.Print "Bit 8 active: " & ((bytSample And &H80) = &H80)

    When a Boolean (which is the end result of a comparison in the debug line) is coerced to a string, you'll see True or False, although in the language of Windows (ie. if you'd have Finnish Windows, you'd see Tosi or Epätosi instead of True or False).

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

  4. #4

    Thread Starter
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: binary reading

    with some changes in penegate's code example, i've managed to do it
    solution:
    VB Code:
    1. Dim fPath As String
    2.     Dim fFile As String
    3.     Dim FF As Long
    4.  
    5.         FF = FreeFile()
    6.         Open fPath For Binary Access Read Lock Write As #FF
    7.             fFile = Space(LOF(FF))
    8.             Get #FF, , fFile
    9.         Close #FF
    10.        
    11.         fFile = Replace(fFile, Chr(0), "")
    12.         txtFile.Text = fFile
    btw, i used this to read a .reg file. the reason why i don't use normal input is because somehow it tends to leave quotation marks out
    Last edited by TheBigB; Jul 10th, 2006 at 11:02 AM.

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