Micro Focus QTP (UFT) Forums
How to skip a For count? - 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: How to skip a For count? (/Thread-How-to-skip-a-For-count)



How to skip a For count? - mv8167 - 10-23-2013

How do i code this For statement thus to skip to the Next for if a "No" flag is encountered?

Code:
For intRow=1 to intRowCount
    DataTable.GetSheet(intSheetDetails).SetCurrentRow(intRow)     

    Flag = "NO"

     Flag=ucase(DataTable("Flag","Details"))

         If  Flag = "YES" Then
                QC_Path=trim(DataTable("QC_Path","Details"))
                TestSetName=trim(DataTable("TestSetName","Details"))    
        Else
                GO TO NEXT ITERATION IN "FOR" STATEMENT
        End If
...
...
...
...
Next



RE: How to skip a For count? - basanth27 - 10-23-2013

You don't need to use an Else, IF the condition of Yes is satisfied, it will get into the IF Then loop, else it will automatically move to the next iteration as For Loop has a Next statement.

Code:
For i = 0 to 10
  If i=5 then
    msgbox "val is 5"
end if
msgbox i
Next

Only on the value 5 it will get pop the msgbox. Otherwise, it will move on to the next values.
Hopefully this is what you were looking for, If not please elaborate on the issue.


RE: How to skip a For count? - mv8167 - 10-23-2013

basanth27

The problem is, that the code ... (after the End If) will always be run. If a No is encountered, I need to go to the Next count. Maybe I need to stick all of my code (70 lines) inside the If statrement?

Thx for your help.