VBScript: Passing Object to Function?
- by ioplex
The below example generates an error:
VBScript compilation error: Cannot use parentheses when calling a Sub
This error does not occur if all parameters are not objects.
Is there a special way to pass object parameters to VBScript functions?
Option Explicit
Dim obj
Function TestFunc(obj)
WScript.Echo "Why doesn't this work?"
End Function
Set obj = CreateObject("Scripting.Dictionary")
obj.Add("key", "val")
TestFunc(obj) ' Error here!