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:05, 9 November 2002 (removing type specifiers). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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


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


See: Xor swap algorithm