Can't Use Parentheses When Calling a Sub - VBScript

女生的网名这么多〃 提交于 2019-12-01 11:56:50

问题


I'm writing this code in VBScript, which I haven't used before in my life.

I wrote this: Replace (strContent, st, arr (k,i), 1)

And it gives me a "Can't Use Parentheses When Calling a Sub" problem. Can anyone please help?

I've tried searching online but nothing helped.

Thank you!


回答1:


Found the answer thanks to Panayot Karabakalov.

We tried using a Call and doing it without parentheses:

Replace strContent, st, arr (k,i), 1

But nothing worked. The solution eventually was:

strContent = Replace (strContent, st, arr (k,i), 1)

Thank you everyone for the quick and helpful responses! You guys never let us down.




回答2:


See this article from Eric Lippert. Basically, when you use a procedure or function like this:

Foobar arg1, arg2, arg3

you must not use parentheses around the argument list. When you use the Call keyword or use the return value of a function in an assignment or a condition, then you must use parentheses around the argument list, e.g.:

Call Foobar(arg1, arg2, arg3)

result = Foobar(arg1, arg2, arg3)

If Foobar(arg1, arg2, arg3) Then
  ...
End If


来源:https://stackoverflow.com/questions/17945213/cant-use-parentheses-when-calling-a-sub-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!