VBScript: Passing Object to Function?

Posted by ioplex on Stack Overflow See other posts from Stack Overflow or by ioplex
Published on 2010-03-19T16:12:37Z Indexed on 2010/03/19 16:21 UTC
Read the original article Hit count: 260

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about vbscript

Related posts about function