我假设您想要Xor
布尔值而不是整数本身的二进制表示。所以我的回答是基于这个假设。
如果您使用 1 forTrue
和 2 for False
,那么我建议您编写一些转换函数。
Private Function IntegerToBoolean(number As Integer) As Boolean
Return If(number = 1, True, False)
End Function
Private Function BooleanToInteger(bool As Boolean) As Integer
Return If(bool, 1, 2)
End Function
然后,使用这些,编写其他函数相当简单:
Private Function IntegerXor(int1 As Integer, int2 As Integer) As Integer
Dim bool1 As Boolean = IntegerToBoolean(int1)
Dim bool2 As Boolean = IntegerToBoolean(int2)
Dim boolResult as Boolean = (bool1 Xor bool2)
Return BooleanToInteger(boolResult)
End Function
等等
显然,您将为表格中的每个数字执行此操作,并且您将为 和 创建附加And
函数Or
。