Jump to content

Xor swap algorithm/Visual basic code

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Rlee0001 (talk | contribs) at 21:00, 9 November 2002 (Created Article, needs explaination.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The following Visual Basic subroutine swaps the values of its parameters using the xor operator.


Sub Swap (Var1 As Integer, Var2 As Integer)
   Var1 = Var1 Xor Var2
   Var2 = Var2 Xor Var1
   Var1 = Var1 Xor Var2
End Sub


See Xor swap algorithm