Exiting an if...then statement in vbscript


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Exiting an if...then statement in vbscript

  1. #1
    Eric Guest

    Exiting an if...then statement in vbscript


    I'm trying to use an if...then statement within a for...next loop to check
    at the outset whether or not a particular value is 0 or not. If it is 0
    (zero), then I want to just exit the if...then statement which will, in theory,
    go right to the 'next' part of the for...next loop and increment the counter.

    Basically, how do I exit an if...then statement like:

    FOR i = 1 TO somenumber
    quantity = request.form("quantity")
    IF quantity = 0 THEN
    'exit the if...then statement
    ELSE
    'execute some code
    END IF
    NEXT





  2. #2
    Douglas J. Steele Guest

    Re: Exiting an if...then statement in vbscript

    Either don't put anything between the IF and THEN, or use:

    FOR i = 1 TO somenumber
    quantity = request.form("quantity")
    IF quantity <> 0 THEN
    'execute some code
    END IF
    NEXT

    --

    Doug Steele, Microsoft Access MVP
    Beer, Wine and Database Programming. What could be better?
    Visit "Doug Steele's Beer and Programming Emporium"
    http://I.Am/DougSteele/


    Eric <ericj@newportinternet.com> wrote in message
    news:390df1b3$1@news.devx.com...
    >
    > I'm trying to use an if...then statement within a for...next loop to check
    > at the outset whether or not a particular value is 0 or not. If it is 0
    > (zero), then I want to just exit the if...then statement which will, in

    theory,
    > go right to the 'next' part of the for...next loop and increment the

    counter.
    >
    > Basically, how do I exit an if...then statement like:
    >
    > FOR i = 1 TO somenumber
    > quantity = request.form("quantity")
    > IF quantity = 0 THEN
    > 'exit the if...then statement
    > ELSE
    > 'execute some code
    > END IF
    > NEXT
    >
    >
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center