Question about For-Next

Discussion in 'ASP General' started by kristofferorstadius@gmail.com, Jan 30, 2006.

  1. Guest

    Hello,

    I have a simple 'For Next'-code (see at the bottom).

    In the middle of the loop I want an IF-statement, which (if it is true)
    jump over to next level.

    I thought I could solve it through simple just writing an IF-statement
    and put Next in the middle, but an error message appears.

    Do you know how I can solve it?

    <%
    For m = 0 To Ubound(minArray,2)

    If Isnull(minArray(0,m)) or minArray(0,m) = "" Then
    Next
    End If

    Response.Write "Hello world!"

    Next
    %>



    Thank you!

    Kristoffer
     
    , Jan 30, 2006
    #1
    1. Advertising

  2. wrote:
    > Hello,
    >
    > I have a simple 'For Next'-code (see at the bottom).
    >
    > In the middle of the loop I want an IF-statement, which (if it is
    > true) jump over to next level.
    >
    > I thought I could solve it through simple just writing an IF-statement
    > and put Next in the middle, but an error message appears.
    >
    > Do you know how I can solve it?
    >
    > <%
    > For m = 0 To Ubound(minArray,2)
    >
    > If Isnull(minArray(0,m)) or minArray(0,m) = "" Then
    > Next
    > End If
    >
    > Response.Write "Hello world!"
    >
    > Next
    > %>
    >
    >

    For the scenario you are describing, you don't need anything special, just
    use your If statement, but in reverse:

    <%
    For m = 0 To Ubound(minArray,2)

    If len(minArray(0,m)) >0 Then
    Response.Write "Hello world!"
    End If


    Next
    %>


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 30, 2006
    #2
    1. Advertising

  3. Roland Hall Guest

    <> wrote in message
    news:...
    : Hello,
    :
    : I have a simple 'For Next'-code (see at the bottom).
    :
    : In the middle of the loop I want an IF-statement, which (if it is true)
    : jump over to next level.
    :
    : I thought I could solve it through simple just writing an IF-statement
    : and put Next in the middle, but an error message appears.
    :
    : Do you know how I can solve it?
    :
    : <%
    : For m = 0 To Ubound(minArray,2)
    :
    : If Isnull(minArray(0,m)) or minArray(0,m) = "" Then
    : Next
    : End If
    :
    : Response.Write "Hello world!"
    :
    : Next
    : %>

    <%
    For m = 0 To Ubound(minArray,2)
    if minArray(0,m) <> "" then Response.Write "Hello world!"
    next
    %>

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Jan 30, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryan
    Replies:
    2
    Views:
    318
    avnrao
    Apr 29, 2004
  2. Deniz Bahar
    Replies:
    2
    Views:
    484
    Andrey Tarasevich
    Mar 9, 2005
  3. =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki

    Reading of file by next of map file and by next of file descriptor.

    =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki, Jul 10, 2007, in forum: C++
    Replies:
    1
    Views:
    802
    Alf P. Steinbach
    Jul 10, 2007
  4. Tad McClellan
    Replies:
    3
    Views:
    156
    Edward Wijaya
    May 13, 2004
  5. Liora
    Replies:
    5
    Views:
    659
    Tad McClellan
    Jan 12, 2007
Loading...

Share This Page