For Programmers: Free Programming Magazines  


Home > Archive > ASP > January 2006 > Question about For-Next









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Question about For-Next
kristofferorstadius@gmail.com

2006-01-30, 7:55 am

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

Bob Barrows [MVP]

2006-01-30, 7:55 am

kristofferorstadius@gmail.com 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.


Roland Hall

2006-01-30, 6:55 pm

<kristofferorstadius@gmail.com> wrote in message
news:1138626111.700774.99810@g47g2000cwa.googlegroups.com...
: 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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com