Sponsored Ad

Thursday, September 30, 2010

QTP Automation: Conditional Exit from For Next loop

This is simple program of using the for loop in QTP automation .

Steps to develop this program:

1. start a for net loop from 0 and end at 10

2. put a if statement inside the for loop and if condition satisfy exit the loop by writing “Exit For”

3. Print the loop counter values inside the loop.

Program Code:

<html>
<body>

<script type="text/vbscript">
For i = 0 To 10
If i=5 Then Exit For
document.write("The loop counter # " & i & "<br />")
Next
</script>

</body>
</html>

Output:

QTP Programming: Conditional Exit from For Next loop

Where to Run This Program:

1. This VBScript Program code either you can use in QTP editor  (code between <script> and </script> tags ) and run it.

2. Write in Notepad, save with .htm extension and run on internet explorer.

2 comments:

  1. This doesn't work in the standard QTP editor. It returns a syntax error.

    ReplyDelete
  2. Please use msgbox in place of document.write()

    ReplyDelete

Sponsored Ad

Development Updates

Tech Updates