strange_steve
New Member
- Joined
- Jun 30, 2015
- Messages
- 1
I have a VBA conditional function I hacked together (I'm a noob) that does a hex 'AND" function on a 36-bit value in a cell with another 36-bit value.
This result is then passed though another function (total hack) that looks for logical '0' other wise it assumes logic '1'. The second part is clunky but works
The problem seem to be in the first function "HexBitAND", which appears to work but when I hit the 32bit boundary the "HexBitAND" function stops working (bit positions 0-31 work fine positions 32-35 do not) perhaps someone can please advise.
Here are the functions:
Function HexBitAND(N1 As String, N2 As String) As String
HexBitAND = Hex$(Val("&H" & N1) And Val("&H" & N2))
End Function
I have attached the second part of the function as additional info:
Function IsZeroOrOne(N1 As String) As String
If N1 = "0" Then
IsZeroOrOne = "0"
Else
IsZeroOrOne = "1"
End If
End Function
Function ZeroOne(N1 As String, N2 As String) As String
ZeroOne = IsZeroOrOne(HexBitAND(N1, N2))
End Function
The main issue is in the HexBitAND function I think the problem is with the "type"
Function HexBitAND(N1 As String, N2 As String) As String
HexBitAND = Hex$(Val("&H" & N1) And Val("&H" & N2))
End Function
For instance :
bit30: N1=FFFFFFCCF N2=040000000 Result = 40000000
bit31: N1=FFFFFFCCF N2=080000000 Result = 80000000
bit32: N1=FFFFFFCCF N2=100000000 Result = 0
bit33: N1=FFFFFFCCF N2=200000000 Result = 0
Thoughts anyone?
This result is then passed though another function (total hack) that looks for logical '0' other wise it assumes logic '1'. The second part is clunky but works
The problem seem to be in the first function "HexBitAND", which appears to work but when I hit the 32bit boundary the "HexBitAND" function stops working (bit positions 0-31 work fine positions 32-35 do not) perhaps someone can please advise.
Here are the functions:
Function HexBitAND(N1 As String, N2 As String) As String
HexBitAND = Hex$(Val("&H" & N1) And Val("&H" & N2))
End Function
I have attached the second part of the function as additional info:
Function IsZeroOrOne(N1 As String) As String
If N1 = "0" Then
IsZeroOrOne = "0"
Else
IsZeroOrOne = "1"
End If
End Function
Function ZeroOne(N1 As String, N2 As String) As String
ZeroOne = IsZeroOrOne(HexBitAND(N1, N2))
End Function
The main issue is in the HexBitAND function I think the problem is with the "type"
Function HexBitAND(N1 As String, N2 As String) As String
HexBitAND = Hex$(Val("&H" & N1) And Val("&H" & N2))
End Function
For instance :
bit30: N1=FFFFFFCCF N2=040000000 Result = 40000000
bit31: N1=FFFFFFCCF N2=080000000 Result = 80000000
bit32: N1=FFFFFFCCF N2=100000000 Result = 0
bit33: N1=FFFFFFCCF N2=200000000 Result = 0
Thoughts anyone?