Solved

# Pass function as parameter

Posted on 2003-03-25

Hi everybody

I would very much like to be able to pass a function or sub as a parameter to another function. I am thinking about something like:

Dim a, b, result

Function Add()

result = a + b

End Function

Function Multiply()

result = a * b

End Function

Function Math(byVal firstarg, byVal secondarg, byRef mathFunction)

a = firstarg

b = secondarg

Call mathFunction

Math = result

End Function

addresult = Math (5,5, Add())

multiplyresult = Math (5,5, Multiply())

The above probably doesn't work. My question is if something like this is possible. To transfer a function as a parameter argument to another function.

I only have VBScript to do this (no JScript)