Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When and when not to use "Parentheses"
#1
Solved: 10 Years, 10 Months ago
Hi,

Using the following option I was successfully exported sheet to C: drive
datatable.Exportsheet "C://sheet1",1

but when I used parentheses similar to below
datatable.Exportsheet ("C://sheet1",1)

QTP throwing syntax error saying "Cannot use parentheses when calling a Sub"

As I don't have much programming knowledge I always get confused with when and when not to use parentheses...
Can any one give tips on how to know about this?
and also what does it mean by the error I mentioned above.

Thanks,
Akhila
Reply
#2
Solved: 10 Years, 10 Months ago
sub refers to subroutine. Always remember these two rules when calling a subroutine:

  1. When calling a subroutine without the Call statement, do not use parentheses.
  2. If you want to use parentheses always use Call statement.

Ex: Call datatable.Exportsheet ("C://sheet1",1)
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 10 Years, 10 Months ago
Thanks Ankur!

One more doubt...

The statement below is not throwing any error even with parentheses, here am not using any Call statement.
Can I know the logic behind it?

DataTable.Export ("C:\flights.xls")

Thanks,
Akhila
Reply
#4
Solved: 10 Years, 10 Months ago
Thanks Ankur,

I am facing same issue as I m not getting any error message

EXBig GrinataTable.Export ("C:\flights.xls")
I did not use "CALL"
Thanks,
Rajendra
Reply
#5
Solved: 10 Years, 10 Months ago
@Akhila, rajendra and others: Here is the answer to your question on When and when not to use parenthesis in VBScript?
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)