Micro Focus QTP (UFT) Forums
When and when not to use "Parentheses" - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: When and when not to use "Parentheses" (/Thread-When-and-when-not-to-use-Parentheses)



When and when not to use "Parentheses" - Akhila - 10-20-2008

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


RE: When and when not to use "Parentheses" - Ankur - 10-20-2008

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)


RE: When and when not to use "Parentheses" - Akhila - 10-22-2008

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


RE: When and when not to use "Parentheses" - rajendra - 11-17-2008

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


RE: When and when not to use "Parentheses" - Ankur - 07-31-2013

@Akhila, rajendra and others: Here is the answer to your question on When and when not to use parenthesis in VBScript?