1

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!

Neta
  • 871
  • 5
  • 14
  • 30

2 Answers2

6

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.

Neta
  • 871
  • 5
  • 14
  • 30
3

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
MeSo2
  • 450
  • 1
  • 7
  • 18
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • 1
    We tried with a "Call" and without parentheses as in your first example and it didn't work. The solution for us was using the return value. – Neta Jul 31 '13 at 05:14