These functions below take a binary string ... [0's and 1's] and inverts the bit
first one gives the binary string back inversed, the second one gives the binary string back inversed, then transformed into hex
i needed this function because if statements i didnt like to do a quick chk to see if a value is 1 or 0, i used this in conjuction with a chkbox setting the others to the opposite of the one selected....useful instead of an if statement --- also useful if ur used to assembly and the "XOR" processor command flipping data into the inverse XD ...
Code:
'// Function takes a binary string, and inverts the values
' then gives it back out as a binary
' chk function underneath for hex answer
Private Function bitXOR(Val As String) As String
For i = 1 To Len(Val)
Select Case Mid$(Val, i, 1)
Case 0:
bitXOR = bitXOR & "1"
Case 1:
bitXOR = bitXOR & "0"
End Select
Next
End Function
Private Function hbitXOR(Val As String) As String
For i = 1 To Len(Val)
Select Case Mid$(Val, i, 1)
Case 0:
hbitXOR = hbitXOR & "1"
Case 1:
hbitXOR = hbitXOR & "0"
End Select
Next
hbitXOR = Hex(Val(hbitXOR))
End Function