Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions: variable parameter list- is it possible?

Status
Not open for further replies.

joelwenzel

Programmer
Jun 28, 2002
448
In some languages, it is possible to get an argument array of a function and access parameters through the array. Is it possible to access this array in vbscript?

Perhaps there are other solutions to my problem. I want to create a function that can be called with a different number of variables each time it is called. In C, function overload could solve my problem. In vbscript, I could pass an array as the argument but it would have to contain all the same type (wouldn't it? I want to pass a recordset, string, and ints).

call foobar(string1, recordset1)
call foobar(string1)

and have the function handle the data differently depending on the number of parameters
 
ParamArray is used in regular VB but apparently never made it to VBScript.
"ParamArray Optional. Used only as the last argument in arglist to indicate that the final argument is an Optional array of Variant elements. The ParamArray keyword allows you to provide an arbitrary number of arguments. It may not be used with ByVal, ByRef, or Optional. "

Sub a(x, ParamArray B())
Dim I
For I = 0 To UBound(B)
Next
End Sub

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top