what is a fast way of reading binary?
thnx in advance
Printable View
what is a fast way of reading binary?
thnx in advance
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:
Dim bytSample As Byte bytSample = 173 Debug.Print "Number is " & bytSample Debug.Print "Bit 1 active: " & ((bytSample And &H1) = &H1) Debug.Print "Bit 2 active: " & ((bytSample And &H2) = &H2) Debug.Print "Bit 3 active: " & ((bytSample And &H4) = &H4) Debug.Print "Bit 4 active: " & ((bytSample And &H8) = &H8) Debug.Print "Bit 5 active: " & ((bytSample And &H10) = &H10) Debug.Print "Bit 6 active: " & ((bytSample And &H20) = &H20) Debug.Print "Bit 7 active: " & ((bytSample And &H40) = &H40) 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).
with some changes in penegate's code example, i've managed to do it
solution:
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 outVB Code:
Dim fPath As String Dim fFile As String Dim FF As Long FF = FreeFile() Open fPath For Binary Access Read Lock Write As #FF fFile = Space(LOF(FF)) Get #FF, , fFile Close #FF fFile = Replace(fFile, Chr(0), "") txtFile.Text = fFile