Code |
BitToLong01 |
Doping: needs reference to StringHelpers typelib Split03.tlb (by Egbert Nierop)
Download TLB_Split03.zip (3KB zipped, VB5-compatible).
Public Function BitToLong01(bitexpr As String) As Long
' by Egbert Nierop, egbert_nierop@goovy.hotmail.com, 20001222
' needs a reference to split03.tlb
'unicode fixed-length array
Dim t(31) As Integer
Dim lLen As Long
lLen = Len(bitexpr)
If lLen <> 32 Then Exit Function
StringHelpers.kernel.MoveMemoryFromStr t(0), bitexpr, 64
For lLen = 1 To 31
BitToLong01 = 2 * BitToLong01 + (t(lLen) Xor 48)
Next
'must do this at last to get rid of overflow in ide mode
If (t(0) Xor 48) = 1 Then
BitToLong01 = BitToLong01 Or &H80000000
End If
End Function
|
BitToLong02 |
Public Function BitToLong02(bitexpr As String) As Long
' by Donald, donald@xbeat.net, 20001228
' based on BitToLong01 by Egbert Nierop, egbert_nierop@goovy.hotmail.com, 20001222
Static abBit() As Byte
Dim i As Long
If LenB(bitexpr) <> 64 Then Exit Function
abBit = bitexpr
For i = 2 To 63 Step 2
BitToLong02 = 2 * BitToLong02 Or (abBit(i) Xor 48)
Next
'must do this at last to get rid of overflow in ide mode
If (abBit(0) Xor 48) Then
BitToLong02 = BitToLong02 Or &H80000000
End If
End Function
|
BitToLong03 |
Doping: needs reference to typelib Split03.tlb (by Egbert Nierop)
Download TLB_Split03.zip (3KB zipped, VB5-compatible).
Public Function BitToLong03(bitexpr As String) As Long
' by Egbert Nierop, egbert_nierop@goovy.hotmail.com, 20001228
' inspired by BitToLong02 by Donald, donald@xbeat.net, 20001228
' needs a reference to split03.tlb
'unicode fixed-length array
Static t(31) As Integer
Dim lLen As Long
lLen = Len(bitexpr)
If lLen <> 32 Then Exit Function
StringHelpers.kernel.MoveMemoryFromStr t(0), bitexpr, 64
For lLen = 1 To 31
BitToLong03 = 2 * BitToLong03 + (t(lLen) Xor 48)
Next
'must do this at last to get rid of overflow in ide mode
If (t(0) Xor 48) = 1 Then
BitToLong03 = BitToLong03 Or &H80000000
End If
End Function
|
BitToLong04 |
Private Declare Sub RtlMoveMemory Lib "kernel32" ( _
dst As Any, src As Any, ByVal nBytes&)
Public Function BitToLong04(bitexpr As String) As Long
' by G.Beckmann, G.Beckmann@NikoCity.de, 20001230
' based on BitToLong03 by Egbert Nierop, egbert_nierop@goovy.hotmail.com, 20001228
Static t%(31): Dim asc0%
If Len(bitexpr) <> 32 Then Exit Function
RtlMoveMemory t(0), ByVal StrPtr(bitexpr), 64
asc0 = KeyCodeConstants.vbKey0
BitToLong04 = t(1) - asc0
BitToLong04 = 2 * BitToLong04 + t(2) - asc0
BitToLong04 = 2 * BitToLong04 + t(3) - asc0
BitToLong04 = 2 * BitToLong04 + t(4) - asc0
BitToLong04 = 2 * BitToLong04 + t(5) - asc0
BitToLong04 = 2 * BitToLong04 + t(6) - asc0
BitToLong04 = 2 * BitToLong04 + t(7) - asc0
BitToLong04 = 2 * BitToLong04 + t(8) - asc0
BitToLong04 = 2 * BitToLong04 + t(9) - asc0
BitToLong04 = 2 * BitToLong04 + t(10) - asc0
BitToLong04 = 2 * BitToLong04 + t(11) - asc0
BitToLong04 = 2 * BitToLong04 + t(12) - asc0
BitToLong04 = 2 * BitToLong04 + t(13) - asc0
BitToLong04 = 2 * BitToLong04 + t(14) - asc0
BitToLong04 = 2 * BitToLong04 + t(15) - asc0
BitToLong04 = 2 * BitToLong04 + t(16) - asc0
BitToLong04 = 2 * BitToLong04 + t(17) - asc0
BitToLong04 = 2 * BitToLong04 + t(18) - asc0
BitToLong04 = 2 * BitToLong04 + t(19) - asc0
BitToLong04 = 2 * BitToLong04 + t(20) - asc0
BitToLong04 = 2 * BitToLong04 + t(21) - asc0
BitToLong04 = 2 * BitToLong04 + t(22) - asc0
BitToLong04 = 2 * BitToLong04 + t(23) - asc0
BitToLong04 = 2 * BitToLong04 + t(24) - asc0
BitToLong04 = 2 * BitToLong04 + t(25) - asc0
BitToLong04 = 2 * BitToLong04 + t(26) - asc0
BitToLong04 = 2 * BitToLong04 + t(27) - asc0
BitToLong04 = 2 * BitToLong04 + t(28) - asc0
BitToLong04 = 2 * BitToLong04 + t(29) - asc0
BitToLong04 = 2 * BitToLong04 + t(30) - asc0
BitToLong04 = t(31) - asc0 + 2 * BitToLong04
If t(0) <> asc0 Then BitToLong04 = BitToLong04 Or &H80000000
End Function
|
Calls |
1 | sRet = BitToLong("00000000000000000000000000000000") --> &H0
|
2 | sRet = BitToLong("10101010101010101010101010101010") --> &HAAAAAAAA
|
3 | sRet = BitToLong("11111111111111111111111111111111") --> &HFFFFFFFF (-1)
|
Charts |
|