|
VBS does not enable optional parameters with function declaration. The function declaration in VBS looks like : [Public | Private] Function name [(arglist)] [statements] [name = expression] [Exit Function] [statements] [name = expression] End Function The arglist argument has the following syntax and parts: [ByVal | ByRef] varname[( )]
function functionname([argument1 [, argument2 [, ...argumentn]]]) Then you can call the function :function sprintf(Templ){ var C = 1; var Pos = Templ.indexOf("%s"); while(Pos>=0){ Templ = Templ.substr(0, Pos) + arguments[C++] + Templ.substr(Pos+2) Pos = Templ.indexOf("%s") } return Templ; };
See alsofor 'ASP and optional parameters' article Copyright and use this code
The source code on this page and other samples at https://www.motobit.com/tips/
are a free code, you can use it as you want: copy it, modify it, use it in your products, ...
If you use this code, please:
1. Leave the author note in the source.
or
2. Link this sample from you page.
<A Href="https://www.motobit.com/tips/detpg_optpar/" Title="Use optional parameters in VBS/JS." >ASP and optional parameters</A> Do you like it? Rate me on LinkedIn |
© 1996 - 2019 Antonin Foller, Motobit Software | About, Contacts