Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Er...tell me again why I can't pass ParamArray to a Function?

Y'all set me straight a year ago on how to "pass" ParamArray to a
another Function (sorry about the Google; don't live in the real
world):

http://groups.google.com/group/micro...f9ce718998a088

Since then, this works:

Function Foo(ParamArray VParams()) As String
Dim V() As Variant
V = VParams
Foo = Bar(V)
End Function

Function Bar(VParams) As String
Dim VParam As Variant
For Each VParam In VParams
FlogSelfForInvestingIn(VParam)
Next
Bar = "Dow go bye-bye."
End Function

***

What I don't understand is why you must use an intermediate var. in
Foo. Why can't you do the more intuitive:

Function Foo(ParamArray VParams()) As String
Foo = Bar(VParams())
End Function

Function Bar(ParamArray VParams()) As String

etc.

Thanks much.

***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Er...tell me again why I can't pass ParamArray to a Function?

Aw, damn it.

My Q was prompted by several hours' worth of trouble today in trying
to remember & reconstruct the syntax I just told you works for me.

Turns out, it appears intermediate var V() is NOT necessary. This
seems to work:

Function Foo(ParamArray VParams()) As String
Foo = Bar(VParams)
End Function

Function Bar(VParams) As String

etc.

So my only Q now is why Bar's parameter can't be parallel to Foo's.

Thanks again.

***
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Er...tell me again why I can't pass ParamArray to a Function?

Because when VParams hits Foo, it is many different parameters, VBA collects
it into an array for ease of use, so you are passing the array on, not each
separate parameter.

--
__________________________________
HTH

Bob

wrote in message
...
Aw, damn it.

My Q was prompted by several hours' worth of trouble today in trying
to remember & reconstruct the syntax I just told you works for me.

Turns out, it appears intermediate var V() is NOT necessary. This
seems to work:

Function Foo(ParamArray VParams()) As String
Foo = Bar(VParams)
End Function

Function Bar(VParams) As String

etc.

So my only Q now is why Bar's parameter can't be parallel to Foo's.

Thanks again.

***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Er...tell me again why I can't pass ParamArray to a Function?

Bob:

OK, thanks very much for answering. I think that sets me straight.

***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Er...tell me again why I can't pass ParamArray to a Function?

I can't get that to work unless I use ByVal as in

Function Bar(Byval VParams) As String

Which is doing a copy anyway, even if its not explicit.

If I don't use ByVal I get a compile error 'Invalid use of ParamArray'

(The reason I don't want to do a copy is for performance reasons when the
parameter is a formula creating a large result set)

Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

wrote in message
...
Aw, damn it.

My Q was prompted by several hours' worth of trouble today in trying
to remember & reconstruct the syntax I just told you works for me.

Turns out, it appears intermediate var V() is NOT necessary. This
seems to work:

Function Foo(ParamArray VParams()) As String
Foo = Bar(VParams)
End Function

Function Bar(VParams) As String

etc.

So my only Q now is why Bar's parameter can't be parallel to Foo's.

Thanks again.

***



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing ParamArray to another function converts it to TWO dimensions. [email protected] Excel Programming 4 January 31st 08 03:35 PM
ParamArray debug anomaly Alan Beban[_2_] Excel Programming 10 November 20th 07 10:57 PM
ParamArray bugs? pinkfloydfan Excel Programming 7 May 30th 07 09:14 PM
Help with paramarray Jeremy Excel Programming 1 January 8th 07 03:48 PM
ParamArray Jim Chandler[_2_] Excel Programming 4 April 28th 04 03:28 PM


All times are GMT +1. The time now is 03:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"