Signature (Visual Basic / VBA)
Public Sub SwapVariants( _
ByRef rOne As Variant _
, ByRef rTwo As Variant _
)
Code Examples
Assuming
Dim varOne As Variant
Dim varTwo As Variant
varOne = "1"
varTwo = "2"
for example
SwapVariants varOne, varTwo
leaves
varOne = "2"
varTwo = "1"
Integer and Variant with Integer value.
String and Variant with String value.
Double and Variant with Long value.
Variant with Integer value and Variant with String value.
Parameters
| Parameter | Description |
|---|---|
| rOne | Value which is to be swapped with that of rTwo. |
| rTwo | Value which is to be swapped with that of rOne. |
Notes & Version History
| Details | For example, the following types of arguments would be compatible: |
| Note | This function modifies both of its arguments (or it generates an error if it cannot do so, such as when one has a String value and the other is has an Integer value and the variables are not Variants). |
| v1.3 BugFix | This Subroutine has been fixed to support the swapping of Object and DataObject type Values. |
| v1.5 Pro Note | Changed the implementation of this function to require one less comparison. |