Cannot use parenthesis when calling a Sub
Question ID: 105396
0
0

Why do I sometimes get ‘Cannot use parenthesis when calling a Sub’ when I try to use a function in my QTP script?

Marked as spam
Posted by (Questions: 227, Answers: 22)
Asked on April 30, 2014 3:02 pm
86 views
Answers (1)
2
Private answer

This is talked about on many VBScripting websites and tutorials, but it basically breaks down into how you are calling or using the function in a script. Below is a summary I found on a VBScript tutorial site a while ago that helps clarify:

If you are using a variable to capture a value returned from a function, you can enclose as many arguments as you need within parenthesis, such as:

return_value = LogMeIn (''user1'',''password1'',''region 5'')

If you are using the optional Call before the function, you can also have many arguments in parenthesis, such as:

Call LogMeIn (''user1'',''password1'',''region 5'')

* Notice there is no return value in the Call statement, but it allows parenthesis

If you are only going to pass one argument into the function AND you are not returning a value back to the calling script, you can put the one argument in parenthesis, such as:

LogMeIn (''user1'')

If you are not using the above situations, usually you not use parenthesis around the arguments of the function. Example:

LogMeIn ''user1'',''password1'',''region 5''

Marked as spam
Posted by (Questions: 2, Answers: 477)
Answered on April 30, 2014 3:04 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top