Hi all,
I've re-worded a previous post on this topic as it remains unresolved:
http://www.mrexcel.com/board2/viewtopic.php?t=120830
I'm writing a function that will accept a ParamArray (ie a variable number of arrays) and automatically redirect that array to be sorted by one of two sort functions based on its size.
My BubbleSort function, declared as:
will correctly sort the three arrays RndNos, Names and Order, based on the order of RndNos, and I call it with:
When I use the following wrapper, however:
with BubbleSort now declared as:
(where tmpArr appears to be necessary to transfer the ParamArray to the next function) I encounter the following problem:
At the end of the BubbleSortWrapper function, Arr is sorted exactly as I want it to be. But upon returning to the calling function, none of the array values have changed!
I find this result interesting as the original call to BubbleSort sorted the arrays correctly, ByRef, so somehow, converting the ParamArray to a Variant and backagain seems to have changed it to ByVal?
This one's been stumping me for some time.. any ideas?
Regards,
Alex
I've re-worded a previous post on this topic as it remains unresolved:
http://www.mrexcel.com/board2/viewtopic.php?t=120830
I'm writing a function that will accept a ParamArray (ie a variable number of arrays) and automatically redirect that array to be sorted by one of two sort functions based on its size.
My BubbleSort function, declared as:
Code:
Sub BubbleSort(Ascending As Boolean, ParamArray Arr() As Variant)
will correctly sort the three arrays RndNos, Names and Order, based on the order of RndNos, and I call it with:
Code:
Call BubbleSort(True, RndNos, Names, Order)
When I use the following wrapper, however:
Code:
Sub BubbleSortWrapper(Ascending As Boolean, ParamArray Arr() As Variant)
Dim tmpArr As Variant
tmpArr = Arr()
Call BubbleSort(Ascending, tmpArr)
Arr() = tmpArr
End Sub
with BubbleSort now declared as:
Code:
Sub BubbleSort(Ascending As Boolean, Arr As Variant)
(where tmpArr appears to be necessary to transfer the ParamArray to the next function) I encounter the following problem:
At the end of the BubbleSortWrapper function, Arr is sorted exactly as I want it to be. But upon returning to the calling function, none of the array values have changed!
I find this result interesting as the original call to BubbleSort sorted the arrays correctly, ByRef, so somehow, converting the ParamArray to a Variant and backagain seems to have changed it to ByVal?
This one's been stumping me for some time.. any ideas?
Regards,
Alex