Alas, this is no easy task - in fact, it's pretty much intractible.
My response to this issue has been to stop using Paramarray arguments, and
instead, take a variant array. The Array function, then makes it easy to pass
a custom-built array of values in-line from calling code. That this seems to
have been the logic of the ADO API as well, since many ADO methods accept
Array values passed to variant arguments.
Example based on your example (untested air code):
Function AverageSequenceOfNumbers( _
SequenceOfNumbers As Variant _
) as Double
Dim varNumItem As Variant
Dim varSumOfNums As Variant
Dim varItemCount As Long
varSumOfNums = 0&
For Each varNumItem in SequenceOfNumbers
varSumOfNums = varSumOfNums + varNumItem
Next
varItemCount = UBound(SequenceOfNumbers) - _
LBound(SequenceOfNumbers) + _
1
AverageSequenceOfNumbers = _
varSumOfNums / varItemCount
End Function
Function AverageSequenceOfNumbersPlusOne( _
SequenceOfNumbers as Variant _
) as Double
Dim varSequencePlusOne As Variant
Dim lngLBound As Long
Dim lngUBound As Long
varSequencePlusOne = SequenceOfNumbers
lngLBound = LBound(varSequencePlusOne)
lngUBound = UBound(varSequencePlusOne)
Redim Preserve varSequencePlusOne(lngLBound To lngUBound+1)
varSequencePlusOne(lngUBound) = 99
AverageSequenceOfNumbersPlusOne = _
AverageSequenceOfNumbers(varSequencePlusOne)
End Function
On 20 Jan 2005 22:12:53 -0800, "Edlueze" <ed*****@onegen.com> wrote:
Greetings:
I have two functions and I would like to pass the ParamArray gathered
from one function to the other function. For the purposes of this post,
let's say that they are calculating averages (they're actually
processing a sequence of pairs of variants and the sequence is of
unknown length).
I want something like these two functions:
#1 Function AverageSequenceOfNumbers(ParamArray SequenceOfNumbers As
Variant) as Double
...
End Function
#2 Function AverageSequenceOfNumbersPlusOne(ParamArray
SequenceOfNumbers as Variant) as Double
AverageSequenceOfNumbersPlusOne = AverageSequenceOfNumbers(99,
SequenceOfNumbers)
End Function
The second function is brand new, but the first function is
tried-and-true code so I don't want to go back and strip out the
ParamArray in the first function and replace it with a regular Array.
In fact, I don't want to touch the first function at all (unless it is
really minor change). If there is not something obvious then is there a
work-around I can implement in the new second function?
Thanks,
Edlueze.