Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there ways to create optional arguments to functions in vb script?

Tags:

vbscript

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. 
like image 633
Rob Segal Avatar asked Dec 11 '09 15:12

Rob Segal


People also ask

How do you make an optional argument a function?

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.

What is optional arguments in VB?

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.

How do I declare optional in VBA?

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.

What are optional function arguments?

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.


2 Answers

The optional keyword (like in VB6) is not allowed in vbscript

maybe this helps: http://www.4guysfromrolla.com/webtech/071801-1.shtml

like image 125
Daniel Kreiseder Avatar answered Sep 22 '22 17:09

Daniel Kreiseder


How about overloading?

like image 21
Josh Stodola Avatar answered Sep 20 '22 17:09

Josh Stodola