Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
skip an iteration in a loop without using if condition...
#1
Solved: 11 Years, 3 Months, 3 Weeks ago Exclamation 
Dear friends,

Recently i had attend an interview and the interviewer ask me a question,

How will you skip a particular iteration from a loop in vb script without using the If condition checking inside the loop. i have no answer for this question and still searching for it.. is there anyone know..pls share it..


Thanks,
Shibin P
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Shibin, Please don't create duplicate threads. We have deleted the other one.

As far as the answer is concerned (unless this is a trick question), one of the methods can be by putting this for loop in a function and making the lower and upper index as variables. So you can have something like

PHP Code:
Function loop_iteration(lower,upper)
...
End Function

'if you wish to skip say nth iteration you can 

Call (lower, n-1)
Call (n+1, upper) 

Others - please contribute your solutions as well.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks for the reply... i hope this is something like writing a loop for 2 times by avoiding the iteration which is not required.. m not sure whether my interviewer want the same...

thanks again...
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Any new reply?????
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Sorry if my reply is so stupid....

if the requirement is not to use 'IF' and 2 for loops...

i will do something like this

Code:
For iterationNo =1 to 100
      Select Case iterationNo
        Case N    ' condition to be skipped
                'Skipping
        Case Else
                ' continues
     End Select
Next
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Dear friend ,

Many thanks for your reply... i m not sure but most probably u may be correct, because may be my interviewer was checking my outbox thinking/analytical skill...

thank you so much...
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
how to make maximum number and minimum number function in QTP
Reply
#8
Solved: 11 Years, 3 Months, 3 Weeks ago
ExitActionIteration
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)