Code |
ByteToBit01 |
Public Function ByteToBit01(b As Byte) As String
' by Donald, donald@xbeat.net, 20001206
Dim i As Long
ByteToBit01 = "00000000"
For i = 0 To 7
If b And 2 ^ i Then
Mid$(ByteToBit01, 8 - i, 1) = "1"
End If
Next
End Function
|
ByteToBit02 |
Public Function ByteToBit02(b As Byte) As String
' by Donald, donald@xbeat.net, 20001206
ByteToBit02 = "00000000"
If b And 1 Then Mid$(ByteToBit02, 8) = "1"
If b And 2 Then Mid$(ByteToBit02, 7) = "1"
If b And 4 Then Mid$(ByteToBit02, 6) = "1"
If b And 8 Then Mid$(ByteToBit02, 5) = "1"
If b And 16 Then Mid$(ByteToBit02, 4) = "1"
If b And 32 Then Mid$(ByteToBit02, 3) = "1"
If b And 64 Then Mid$(ByteToBit02, 2) = "1"
If b And 128 Then Mid$(ByteToBit02, 1) = "1"
End Function
|
ByteToBit03 |
Public Function ByteToBit03(b As Byte) As String
' by Donald, donald@xbeat.net, 20001206
ByteToBit03 = "00000000"
If b And 1 Then Mid$(ByteToBit03, 8, 1) = "1"
If b And 2 Then Mid$(ByteToBit03, 7, 1) = "1"
If b And 4 Then Mid$(ByteToBit03, 6, 1) = "1"
If b And 8 Then Mid$(ByteToBit03, 5, 1) = "1"
If b And 16 Then Mid$(ByteToBit03, 4, 1) = "1"
If b And 32 Then Mid$(ByteToBit03, 3, 1) = "1"
If b And 64 Then Mid$(ByteToBit03, 2, 1) = "1"
If b And 128 Then Mid$(ByteToBit03, 1, 1) = "1"
End Function
|
ByteToBit04 |
Public Function ByteToBit04(b As Byte) As String
' by Donald, donald@xbeat.net, 20001227
Static abBits(15) As Byte
abBits(14) = (b And 1) + 48
abBits(12) = (b \ 2 And 1) + 48
abBits(10) = (b \ 4 And 1) + 48
abBits(8) = (b \ 8 And 1) + 48
abBits(6) = (b \ 16 And 1) + 48
abBits(4) = (b \ 32 And 1) + 48
abBits(2) = (b \ 64 And 1) + 48
abBits(0) = (b \ 128) + 48
ByteToBit04 = abBits
End Function
|
ByteToBit05 |
Public Function ByteToBit05(ByVal b As Long) As String
' by Donald, donald@xbeat.net, 20001227
Static abBits(15) As Byte
Dim i As Long
For i = 14 To 0 Step -2
abBits(i) = (b And 1) + 48
b = b \ 2
Next
ByteToBit05 = abBits
End Function
|
ByteToBit06 |
Public Function ByteToBit06(ByVal b As Long) As String
' by Egbert Nierop, egbert_nierop@goovy.hotmail.com, 20001221
Dim cx As Long
ByteToBit06 = "00000000"
For cx = 8 To 1 Step -1
If b And 1 Then Mid$(ByteToBit06, cx, 1) = "1"
b = b \ 2 'shift right
Next
End Function
|
ByteToBit07 |
Public Function ByteToBit07(b As Byte) As String
' by Donald, donald@xbeat.net, 20001221
Dim i As Long
Dim bit As Long
ByteToBit07 = "00000000"
bit = 1
For i = 8 To 1 Step -1
If b And bit Then Mid$(ByteToBit07, i, 1) = "1"
bit = bit * 2
Next
End Function
|
ByteToBit08 |
Public Static Function ByteToBit08(b As Byte) As String
' by Peter Nierop, pnierop.pnc@inter.nl.net, 20001223
Dim lDone&, sNibble(0 To 15) As String
If lDone = 0 Then
sNibble(0) = "0000"
sNibble(1) = "0001"
sNibble(2) = "0010"
sNibble(3) = "0011"
sNibble(4) = "0100"
sNibble(5) = "0101"
sNibble(6) = "0110"
sNibble(7) = "0111"
sNibble(8) = "1000"
sNibble(9) = "1001"
sNibble(10) = "1010"
sNibble(11) = "1011"
sNibble(12) = "1100"
sNibble(13) = "1101"
sNibble(14) = "1110"
sNibble(15) = "1111"
lDone = 1
End If
ByteToBit08 = sNibble(b \ 16 And &HF) & sNibble(b And &HF)
End Function
|
ByteToBit09 |
Public Function ByteToBit09(ByVal b As Long) As String
' by Jost Schwider, jost@schwider.de, 20001227
Dim i As Long
ByteToBit09 = "00000000"
i = 15
Do While b
If b And 1 Then MidB$(ByteToBit09, i) = "1"
b = b \ 2
i = i - 2
Loop
End Function
|
ByteToBit10 |
Public Function ByteToBit10(ByVal b As Long) As String
' by Jost Schwider, jost@schwider.de, 20001228, rev 001
' based on ByteToBit02 by Donald, donald@xbeat.net, 20001206
ByteToBit10 = "00000000"
If b And &H1& Then MidB$(ByteToBit10, 15&) = "1"
If b And &H2& Then MidB$(ByteToBit10, 13&) = "1"
If b And &H4& Then MidB$(ByteToBit10, 11&) = "1"
If b And &H8& Then MidB$(ByteToBit10, 9&) = "1"
If b And &H10& Then MidB$(ByteToBit10, 7&) = "1"
If b And &H20& Then MidB$(ByteToBit10, 5&) = "1"
If b And &H40& Then MidB$(ByteToBit10, 3&) = "1"
If b And &H80& Then MidB$(ByteToBit10, 1&) = "1"
End Function
|
ByteToBit11 |
Public Static Function ByteToBit11(ByVal b As Long) As String
' by Jost Schwider, jost@schwider.de, 20001227
Dim i As Long
Dim sByte(0 To 255) As String
If i Then
ByteToBit11 = sByte(b)
Else
For i = 0 To 255
sByte(i) = ByteToBit10(i)
Next i
ByteToBit11 = sByte(b)
End If
End Function
|
ByteToBit12 |
Public Static Function ByteToBit12(ByVal b As Long) As String
' by Peter Weighill, pweighill@btinternet.com, 20010101
' based on ByteToBit11 by Jost Schwider, jost@schwider.de, 20001227
Dim sByte(0 To 255) As String
If LenB(sByte(b)) = 0 Then
sByte(b) = ByteToBit10(b)
End If
ByteToBit12 = sByte(b)
End Function
|
ByteToBit13 |
Public Static Function ByteToBit13(ByVal b As Long) As String
' by Donald, donald@xbeat.net, 20010102
' based on ByteToBit11 by Jost Schwider, jost@schwider.de, 20001227
Dim i As Long
Dim sByte(0 To 255) As String * 8
If i Then
ByteToBit13 = sByte(b)
Else
For i = 0 To 255
sByte(i) = ByteToBit10(i)
Next i
ByteToBit13 = sByte(b)
End If
End Function
|
Calls |
1 | sRet = ByteToBit(&H0) --> "00000000"
|
2 | sRet = ByteToBit(&HAA) --> "10101010"
|
3 | sRet = ByteToBit(&HFF) --> "11111111"
|
4 | sRet = ByteToBit([0 to 255]) --> all possible values
|
Charts |
|