tags:

views:

133

answers:

4

Forgive me if the answer is obvious as it has been a long time since I have programmed vbscript.

Are there any avantages to using Call when calling a function in vbscript?

For example:

SomeFunction param1, param2

vs

Call SomeFunction (param1, param2)
+6  A: 

No, there is not.

svinto
+8  A: 

The difference as per MSDN -

To call a Sub procedure from another procedure, type the name of the procedure along with values for any required arguments, each separated by a comma. The Call statement is not required, but if you do use it, you must enclose any arguments in parentheses.

The following example shows two calls to the MyProc procedure. One uses the Call statement in the code; the other doesn't. Both do exactly the same thing.

Call MyProc(firstarg, secondarg)
MyProc firstarg, secondarg

Notice that the parentheses are omitted in the call when the Call statement isn't used.

Mohit Chakraborty
A: 

Call is usually used for subroutines and not functions, but either way there is no differences. However when it comes to functions you can retrieve a value return from the function, where as a subroutine can not. Example

result = SomeFunction("param1")

Function SomeFunction(someArg)
SomeFunction = someArg & "Hey There"
End Function

this would return "param1 Hey There" to the "result" value

result = SomeSub("param1")

Sub SomeSub(someArg)
SomeSub = someArg & "Hey There"
End Sub

but in this case "result" won't have any value, because subroutines can't do this.

mrTomahawk
A: 

It really just depends on how much you like parenthesis. Coming from a c-family background, it looks incredibly odd to me to not have them.