![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
#12
| |||
| |||
|
#13
| |||
| |||
|
#14
| |||
| |||
|
|
RTK incorrectly stated that the modified values of elements passed into a ParamArray is not and cannot be returned to the calling routine. |
#15
| |||
| |||
|
|
rkc <rkc (AT) rochester (DOT) yabba.dabba.do.rr.bomb> wrote: : Chuck Grimsby wrote: :> On Fri, 08 Jul 2005 02:45:12 GMT, rkc :> <rkc (AT) rochester (DOT) yabba.dabba.do.rr.bomb> wrote: : : :>>Chuck Grimsby wrote: : :>>>You can also pass a bunch of variables to a function as a ParamArray: :>>>(This example was actually written by Joe Foster, of "Nuke Me Zemu" :>>>legend) :>>>Function RowAvg(ParamArray Stuff() As Variant) As Variant : You're right. So let's add that a paramarray is always optional, must : always be the last argument in the list and is always passed ByVal. : Always being passed ByVal means it can't be used as a way to : return values to the calling code. Does the ParamArray type have any useful function other than reminding the coder what [s]he's doing? I would write such code using an ordinary array and restricting it for the functionality that I needed. Maybe that's because I've never written code for a large project where it's assumed that someone else will need to expand and maintain it. |
#16
| |||
| |||
|
|
You can also pass a bunch of variables to a function as a ParamArray: (This example was actually written by Joe Foster, of "Nuke Me Zemu" legend) snip |
#17
| |||
| |||
|
|
On Fri, 08 Jul 2005 02:45:12 GMT, rkc rkc (AT) rochester (DOT) yabba.dabba.do.rr.bomb> wrote: Chuck Grimsby wrote: You can also pass a bunch of variables to a function as a ParamArray: (This example was actually written by Joe Foster, of "Nuke Me Zemu" legend) Function RowAvg(ParamArray Stuff() As Variant) As Variant That's nice, but using an array of a defined type would clear up what the function actually expected to be passed in. It's tough to guarantee a result when your only argument will except any number of any data type, including objects. Personally, I quite agree! Indeed, I tend to write code in exactly that fashion myself, but I also think it's important to know _all_ the options, not just those I happen to agree with. |
#18
| |||
| |||
|
|
rkc <rkc (AT) rochester (DOT) yabba.dabba.do.rr.bomb> wrote: : Chuck Grimsby wrote: :> On Fri, 08 Jul 2005 02:45:12 GMT, rkc :> <rkc (AT) rochester (DOT) yabba.dabba.do.rr.bomb> wrote: : : :>>Chuck Grimsby wrote: : :>>>You can also pass a bunch of variables to a function as a :>>>ParamArray: (This example was actually written by Joe Foster, :>>>of "Nuke Me Zemu" legend) :>>>Function RowAvg(ParamArray Stuff() As Variant) As Variant : You're right. So let's add that a paramarray is always optional, : must always be the last argument in the list and is always passed : ByVal. Always being passed ByVal means it can't be used as a way : to return values to the calling code. Does the ParamArray type have any useful function other than reminding the coder what [s]he's doing? I would write such code using an ordinary array and restricting it for the functionality that I needed. Maybe that's because I've never written code for a large project where it's assumed that someone else will need to expand and maintain it. |

#19
| |||
| |||
|
|
I answered this question in a previous post, in a context where my answer didn't make much sense. ![]() I wrote: Passing a parameter array, though, is extremely useful for cases where you want to pass multiple values, all of the same type, but don't know until runtime exactly how many. It's a stupid example, but what if you had a function that concatenated a list of items and returned them as a list. With a parameter array, you don't need to know how many items your passing in. |
![]() |
| Thread Tools | |
| Display Modes | |
| |