You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
426 B
Plaintext

Function BinToInt(binvalue)
Dim i, s, v, neg, ilen, value
value = Null
If IsBin(binvalue) Then
value = 0
s = binvalue
ilen = Len(s)
If (ilen=32) Then
v = Left(s, 1)
neg = (CByte(v) = 1)
If neg Then
s = BinNot(s)
End If
End If
s = StrReverse(s)
For i = 1 To ilen
value = value + CByte(Mid(s, i, 1)) * Power(2, i-1)
Next
If neg Then
value = -(value + 1)
End If
End If
BinToInt = value
End Function