Micro Focus QTP (UFT) Forums
Exiting For statement - 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: Exiting For statement (/Thread-Exiting-For-statement)



Exiting For statement - mv8167 - 10-03-2011

I have 3 For statements. I have an If x = 2, I want the k For loop to Exit. But, instead the i For loop i[/quote]s being exited.

Code:
For i = 1 to 4
  For j = 1 tp 5
     For k = 1 to 6
         If x = 2 then
            Exit For
         End If
     Next
  Next
Next

How can I Exit the k For loop?


RE: Exiting For statement - supputuri - 10-03-2011

Hi,
"For...Next" but not "For ... Do".

Thanks,
Sridhar


RE: Exiting For statement - mv8167 - 10-04-2011

I was in a hurry, I changed it.... thx ;-)


RE: Exiting For statement - parminderdhiman84 - 10-04-2011

Hi,

The code is correct and the only K For Loop will be exited. May be you are making some other mistake. Could you please paste the rest of the code.

Regards,
Parminder


RE: Exiting For statement - mv8167 - 10-05-2011

Parminder,

Thx! I thought it should work as you mentioned. I ended up removing the "K" For loop and replaced with a counter. So, I think I am in good shape now.

Lorena