VBScript functions return just a single value. If you assign multiple values to the function name as in your example:
func = a + b
func = a * b
func = b / a
only the last value (the result of b / a
) will be returned.
To have a function return multiple values you need to wrap the values in a datastructure and return that one datastructure. That could be an array
func = Array((a+b), (a*b), (b/a))
a dictionary
Set d = CreateObject("Scripting.Dictionary")
d.Add "add", (a+b)
d.Add "mul", (a*b)
d.Add "div", (b/a)
Set func = d
a custom object
Class CData
Public add, mul, div
End Class
...
Set c = New CData
c.add = a+b
c.mul = a*b
c.div = b/a
Set func = c
an ArrayList
Set a = CreateObject("System.Collections.ArrayList")
a.Add (a+b)
a.Add (a*b)
a.Add (b/a)
Set func = a
or some other collection.
Note that for returning objects you need to use the Set
keyword when assigning the return value of the function:
Set temp = func(a, b)