hi i want to know how to swap 2 variables in vb without using a temporary variable. thank you for the answer ^_^ god bless!!!!!
Swap variables without using a temporary to hold value
Collapse
X
-
Originally posted by clidezzzZhi i want to know how to swap 2 variables in vb without using a temporary variable.
I don't know about later versions, but VB6 doesn't seem to have a built-in swap. You could always create your own Sub and make it a standard part of your toolkit. It's a pretty simple function. Something along the lines of...
[CODE=vb]Public Sub SwapVariables(V ar1 As Variant, Var2 As Variant)
Dim TempVar As Variant
TempVar = Var1
Va1 = Var2
Var2 = TempVar
End Sub[/CODE]To use it, you would just say SwapVariables A, B.
Comment