DR> How do can I read the individual bits that are inside a byte?
The following started life as QB code which I've reworked to VB code,
but you should be able to do something with it. I did not originally
write this.
QB doesn't have a Byte data type, so you will be working with signed
integers.
sBin = "01100101"
iBin2Int(sBin) returns the integer value of sBin
Public Function iBin2Int(sBin)
Dim iY, iZ, iAX
For iY = Len(sBin) To 1 Step -1
If Mid$(sBin, iY, 1) = "1" Then
iAX = iAX + (2 ^ iZ)
End If
iZ = iZ + 1
Next
iBin2Int = iAX
End Function
iDec = 233
sInt2Bin(iDec) returns the byte value of iDec
Public Function sInt2Bin(iDec)
Dim iTDec, sBin
iTDec = iDec
Do While iTDec > 0
If iTDec / 2 = iTDec \ 2 Then
sBin = "0" & sBin
ElseIf iTDec / 2 iTDec \ 2 Then
sBin = "1" & sBin
End If
iTDec = iTDec \ 2
Loop
Do While Len(sBin) < 8 ' byte size only
sBin = "0" & sBin
Loop
sInt2Bin = sBin
End Function
--- PPoint 2.00
---------------
* Origin: Vanishing Point (1:15/7.1)
|