如何求几个数的异或值

netfor2000 2003-02-20 01:27:02
有数据A,B,C,D 用VB如何求得ABCD四的异或值?
...全文
388 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sean918 2003-02-20
  • 打赏
  • 举报
回复
Visual Basic Scripting Edition Language Reference

--------------------------------------------------------------------------------

Xor Operator
Performs a logical exclusion on two expressions.

result = expression1 Xor expression2

Arguments
result

Any numeric variable.

expression1

Any expression.

expression2

Any expression.

Remarks
If one, and only one, of the expressions evaluates to True, result is True. However, if either expression is Null, result is also Null. When neither expression is Null, result is determined according to the following table:

If expression1 is And expression2 is Then result is
True True False
True False True
False True True
False False False


The Xor operator also performs a bitwise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following table:

If bit in expression1 is And bit in expression2 is Then result is
0 0 0
0 1 1
1 0 1
1 1 0

好好看看 操作符  XOR
zw_yu 2003-02-20
  • 打赏
  • 举报
回复
Public Function funJiaMi(inStrs As String, pwsStr As String) As String
Dim inLen As Long, pwsLen As Long
Dim i As Long, j As Long

funJiaMi = ""
inLen = Len(inStrs)
pwsLen = Len(pwsStr)
j = 0
For i = 0 To inLen - 1
j = j + 1
funJiaMi = funJiaMi + Chr((Asc(Mid(inStrs, i + 1, 1)) Xor Asc(Mid(pwsStr, j, 1))))
If j = pwsLen Then j = 0
Next
End Function


Private Sub Form_Load()
msgbox funJiaMi("鱼猫","zw_yu")
end sub
zw_yu 2003-02-20
  • 打赏
  • 举报
回复
Asc(A) Xor Asc(B) Xor Asc(C) Xor Asc(D)

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧