Micro Focus QTP (UFT) Forums
Question of looping through the data table - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Question of looping through the data table (/Thread-Question-of-looping-through-the-data-table)



Question of looping through the data table - sunny rao - 11-17-2008

hi Ankur and all,

Again one basic question regarding looping through all datatable rows,
I write values 1,2,3,4 in four rows of TCNo column in the Datatable and write the code below.

Code:
Tccount = DataTable.GetSheet("Global").GetRowCount
FormulaVal=DataTable.GetSheet("Global").GetParameter("TCNo").RawValue

For Currentrow=1 to  Tccount
Currentrow=Currentrow+FormulaVal-1

msgbox Currentrow
Next


My question is: In the first run the script goes through the loop 4 times then exits, then again the Variable FormulaVal takes on the value of the next row and For... next loop is executed. How is this possible ? and can you suggest a efficient way of reading the total no. of rows and then looping through for Data driven testing.


RE: Question of looping through the data table - sunny rao - 11-18-2008

Changed the Action call property as run one iteration, instead of run on all rows. This solved the above problem.

Still somebody can suggest [ a efficient way of reading the total no. of rows and then looping through for Data driven testing].


RE: Question of looping through the data table - tester_rahul - 02-24-2010

HI You can use the following code:

Code:
For i = 1 to datatable.getrowcount
   'print datatable("Name")
  datatable.setnextrow    
Next


There is another suggestion, you can use print instead of msgbox(). Try it Smile

Thanks,Rahul.