[AccessD] Feeding an paramarray to a paramarray

Drew Wutka DWUTKA at Marlow.com
Wed Mar 12 12:09:38 CDT 2008


Not really, but I'm like House when it comes to code, when I see a
problem that I find intriguing, I have to fix it! ;)

So, did this help ya?

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, March 12, 2008 12:02 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Feeding an paramarray to a paramarray

LOL.  You have too much time on your hands. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka
Sent: Wednesday, March 12, 2008 12:56 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Feeding an paramarray to a paramarray

Ok, one method would be to hand off the actual work to another function,
(a
recursive function) that knows it's getting an array:

Dim tmpSum As Long
Dim strTemp As String
Function RunningSum(ParamArray tmpValues() As Variant) Dim
tmpCurrentValue
As Long strTemp = ""
tmpSum = 0
DoTheWorkForRunningSum tmpValues
strTemp = Left(strTemp, Len(strTemp) - 3) If Val(strTemp) <> tmpSum Then
Debug.Print strTemp & " = " & tmpSum tmpCurrentValue = tmpSum If tmpSum
<
10000 Then RunningSum tmpCurrentValue, tmpValues End Function Function
DoTheWorkForRunningSum(ByVal tmpPossibleArray As Variant) Dim tmpElement
For
Each tmpElement In tmpPossibleArray
    If IsArray(tmpElement) Then
        DoTheWorkForRunningSum tmpElement
    Else
        tmpSum = tmpSum + Val(tmpElement)
        strTemp = strTemp & tmpElement & " + "
    End If
Next
End Function

?RunningSum(1)
1 + 1 = 2
2 + 1 + 1 = 4
4 + 2 + 1 + 1 = 8
8 + 4 + 2 + 1 + 1 = 16
16 + 8 + 4 + 2 + 1 + 1 = 32
32 + 16 + 8 + 4 + 2 + 1 + 1 = 64
64 + 32 + 16 + 8 + 4 + 2 + 1 + 1 = 128
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 + 1 = 256
256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 + 1 = 512
512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 + 1 = 1024
1024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 + 1 = 2048
2048 + 1024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 + 1 = 4096
4096 + 2048 + 1024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 + 1
=
8192
8192 + 4096 + 2048 + 1024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 +
1 + 1 = 16384

To be continued.....

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, March 12, 2008 10:49 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Feeding an paramarray to a paramarray

Drew,

LOL.

>Ya learn something new everyday.

Would you speak into the microphone please...

The "solution" did the trick, but at the expense of eliminating the
ability
to pass in multiple arguments to SecondParamfunction.  It is the keyword
ParamArray that allows the passing in of multiple arguments.  It is
often
useful to have two functions, BOTH of which have param arrays, and be
able
to call either one directly, but also call one from the other.  It is
the
"call one from the other" that is not possible if both have paramarrays.

ParamArrays are indeed a neat trick and one I use all of the time.  What
would be REALLY cool would be to be able to pass into TWO paramarrays
but
that is syntactically impossible - there is no way to denote where
parameters aimed at one array ends and where the parameters aimed at the
next array begins.  The language could be expanded to allow a semicolon
to
denote the end of one list and the beginning of the next but that
doesn't
currently exist.

John W. Colby
Colby Consulting
www.ColbyConsulting.com
The information contained in this transmission is intended only for the
person or entity to which it is addressed and may contain II-VI
Proprietary
and/or II-VI Business Sensitive material. If you are not the intended
recipient, please contact the sender immediately and destroy the
material in
its entirety, whether electronic or hard copy. You are notified that any
review, retransmission, copying, disclosure, dissemination, or other use
of,
or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited.


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.





More information about the AccessD mailing list