Below is VBS code that provides the same functionality as ParamArray modifier in VBA: it allows to pass arbitrary number of arguments, and called function receives passed arguments as array. It uses ScriptControl JScript arguments property to prepare the array of arguments.
Dim oSC, Echo
Set oSC = CreateObject("MSScriptControl.ScriptControl")
oSC.Language = "JavaScript"
oSC.AddCode "echo = function () {var dict = new ActiveXObject('Scripting.Dictionary'); for(var i=0; i<arguments.length; i++) {dict.add(i, arguments[i]);} echoArr(dict.Items());}"
oSC.AddObject "echoArr", GetRef("EchoArr"), True
Set Echo = oSC.Eval("echo")
Echo "one", "two", "three"
Echo "True variadic sub"
Function EchoArr(arr)
WScript.Echo Join(arr)
End Function
To call WScript.Echo in variadic method manner you can use Execute, and replace EchoArr function in code above with following code (but I am not sure it has practical value):
Function EchoArr(arr)
Dim s, i
s = "WScript.Echo "
i = 0
For i = 0 to UBound(arr)
s = s & "arr(" & i & ")"
If i < UBound(arr) Then s = s & ", "
Next
Execute s
End Function
printf-style function, where placeholders are replaced with values?