Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 443
  • Last Modified:

For each statement in asp

Hi
I am working in classic asp and i am using foreach statement as  below
for each member in abc.items
....
....
.....
next
i want to use if condition inside foreach and loop thru it,if my condition is met i want to move to next record omitting rest of the code.how can i do it?
example: i want to loop thru all the members and move to next record if my condition is met(i.e age <18)
can i use move next?
for each member in abc.items
if age<18 then
move next
else
....
....
.....
next

thanks


0
tracy_p
Asked:
tracy_p
3 Solutions
 
Louis01Commented:
Couldn't you rather use a counter?
for i = 0 to abc.items.length - 1
    set member = abc.items(i)
    if member.property = true then i=i+1
.....
next i

0
 
rhodesbCommented:
You can't skip iterations with a For Each Next loop in VBScript.
Simply omit your next statement so:
if age < 18 then
  ' do nothing
else
  ' do everything else
end if
next
0
 
mmaxwell43534Commented:
I agree with rhodesb, but I would do it as
For Each member in abc.items
   If Not age>17 Then
      'do everything
   End If
Next
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now