Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem in looping statements...
#1
Not Solved
Hi,

I have a datasheet containing 'n' number of rows...
i am trying to read the number of rows present in a datasheet and using For loop statement ... tried to get each row of data and able to perform my actions as per the requirements...

but my problem is that it is going to infinite loop after 'n' number of rows are done...

pls find the below piece of code...

Code:
For i=1  to rowcount
   DataTable.SetCurrentRow(i)
   statemnts...
   .
   .
   .
Next

so as to avoid infinite loop we can do
Code:
if  i =  rowcount
    exit...

but the normal FOR syntax without any special checkings should work right...

can anyone tell me how to solve this with out using special checks apart from normal FOR syntax... or correct me if iam doing wrong in using FOR syntax


Thanks
Navya
Reply
#2
Not Solved
Please check what is the value of rowcount using following syntax
msgbox rowcount
For i=1 to rowcount
msgbox rowcount
DataTable.SetCurrentRow(i)
statemnts...
.
.
.
Next
Reply
#3
Not Solved
sorry to mention that in my post ... i am getting the correct value only and i already did checked the rowcount value...
and it is comming correctly as per the rows present in the datasheet

problem is with infiniteloop only...


Thanks..
Navya
Reply
#4
Not Solved
some have able to trace out the solution...


Code:
For i=1  to rowcount

        DataTable.SetCurrentRow(i)
       statements..
       .
       .
       .
       If  i= rowcount  Then
               ExitTest
       End If
   Next

by using the above statement only i was able to comeout (infinite loop) of QTP...



Thanks
Navya
Reply
#5
Not Solved
first use the getrowcount method to get number of used rows into a variable and then use it in the loop
eg x=datatable.localsheet or globalsheet.getrowcount
for i=1 to x step 1
.
.
.
.
Reply
#6
Not Solved
I think you have set "Run on all rows" option in file>settings>run
Change it to "one iteration only"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to use looping statement dmvelic083185 1 1,278 09-26-2017, 08:46 PM
Last Post: Ankur
  Excel_Datasheet Looping problem Saadat Chowdhury 0 1,732 10-05-2012, 08:42 AM
Last Post: Saadat Chowdhury
  Is there a better way to manage my If statements? mv8167 0 1,891 09-03-2011, 01:14 AM
Last Post: mv8167
  Anyone know the difference of the 2 statements martinlam 3 4,009 08-31-2010, 02:44 PM
Last Post: QTPLearn
  Looping wont stop laura 3 3,170 07-06-2009, 02:11 PM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)