Is there ways to create optional arguments to functions in vb script allowing you to write functions something like...
myFunc("happy") myFunc("happy", 1, 2, 3) myFunc("happy", 1) etc.
You can assign an optional argument using the assignment operator in a function definition or using the Python **kwargs statement. There are two types of arguments a Python function can accept: positional and optional. Optional arguments are values that do not need to be specified for a function to be called.
Optional parameters are indicated by the Optional keyword in the procedure definition. The following rules apply: Every optional parameter in the procedure definition must specify a default value. The default value for an optional parameter must be a constant expression.
The optional parameter(s) must be at the end of the parameter list. The IsMissing function will work only with parameters declared as Variant . It will return False when used with any other data type. User defined types (UTDs) cannot be optional parameters.
Optional arguments enable you to omit arguments for some parameters. Both techniques can be used with methods, indexers, constructors, and delegates. When you use named and optional arguments, the arguments are evaluated in the order in which they appear in the argument list, not the parameter list.
The optional keyword (like in VB6) is not allowed in vbscript
maybe this helps: http://www.4guysfromrolla.com/webtech/071801-1.shtml
How about overloading?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With