function argument list... 
Author Message
 function argument list...

Hi,

I was wondering if we can declare a function without specify the number of
arguments its going to have and call that function with any number of
arguments?

Something similar in JScript is:

function myFunc() {
    for (i=0; i < myFunc.arguments.length; i++)
    -----
    -----
    myFunc.arguments[i] ;
    -----
    -----

Quote:
}

Thanks in advance.

Saqib.



Fri, 11 Apr 2003 03:00:00 GMT  
 function argument list...

Quote:

> Hi,

> I was wondering if we can declare a function without specify the number of
> arguments its going to have and call that function with any number of
> arguments?

> Something similar in JScript is:

> function myFunc() {
>     for (i=0; i < myFunc.arguments.length; i++)
>     -----
>     -----
>     myFunc.arguments[i] ;
>     -----
>     -----
> }

> Thanks in advance.

> Saqib.

No, there is no (specific) provision for optional arguments in
VBScript.  However, a common work around is to pass an array as the
single argument and code the function/subroutine to handle an array of
arbitrary length, something like this ...

  result1 = Summation(Array(Var1, Var2, Var3))
  result2 = Summation(Array(A, B, C, D, E))

Function Summation(aVector)
  dim nTemp, I
  for I in 0 to UBound(aVector)
    nTemp = nTemp + aVector(I)
  Next
  Summation = nTemp
End Function

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Fri, 11 Apr 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Question on the Function Argument List

2. Passing argument list to functions

3. variable size argument list in vbs?

4. Unable to execute - arguments list is too long

5. variable argument list?

6. argument list too long errors

7. Arguments list.

8. Unable to execute - arguments list is too long

9. unable to execute - arguments list is too long...

10. Using list dropdown of constants that pertain to a specific argument

11. passing variable argument list from web page to web service (is it possible)

12. arguments list

 

 
Powered by phpBB® Forum Software