For each statement in asp

Posted on 2008-11-07
Last Modified: 2012-05-05
I am working in classic asp and i am using foreach statement as  below
for each member in abc.items
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 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


Question by:tracy_p
    LVL 11

    Assisted Solution

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

    LVL 4

    Assisted Solution

    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
      ' do everything else
    end if
    LVL 2

    Accepted Solution

    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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now