For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > May 2005 > loop









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 loop
Amanda Hallock

2005-05-30, 8:55 pm

I'm trying to make a table with values I pulled from a recordset - for
example a table has rows a,b,c and cols 1,2,3. Each row is formed by a
loop, but I don't necessarily have values for each cell- the row is
determined by one of the fields- (in the example "y" specifies the row)

how do I start the loop over in the middle of the loop?

specifcally:
dbrs.MoveFirst()
do while not dbrs.eof
dbrs. Move(0)
x = dbrs("x")
y = dbrs("y")

%>
<tr>
<% if x = "a1" then
response.write("<td>" & value1 & "</td>")
else
response.write("<td></td>")
end if
dbrs.MoveNext
y2 = dbrs("y")
if y2 = y1 then
'continue with code
else
response.write("<td colspan=2></td></tr>")
' ? goto beginning of loop
end if
%>
<td>
<% if x = "a2" then
response.write("<td>" & value2 & "</td>")
else
response.write("<td></td>")
end if
dbrs.MoveNext
y2 = dbrs("y")
if y2 = y1 then
'continue with code
else
response.write("<td></td></tr>")
' ? goto beginning of loop
end if
%>
<td>
<% if x = "a3" then
response.write("<td>" & value3 & "</td>")
else
response.write("<td></td>")
end if
%>
</tr>
<%
dbrs.MoveNext
loop
%>

Thanks, Amanda


*** Sent via Developersdex http://www.developersdex.com ***
Saga

2005-05-31, 3:55 pm


Place

dbrs.MoveFirst()

where you have

> ' ? goto beginning of loop


The above will start the loop over. Now if what you want
is to just move on to the next loop item, then you need to
nest your IF statements in such a way so that no further
code within the loop will be excuted until the next time
around.

Good luck
Saga

"Amanda Hallock" <amanda2@southwind.org> wrote in message
news:Oa0cx8UZFHA.1404@TK2MSFTNGP09.phx.gbl...
> I'm trying to make a table with values I pulled from a recordset - for
> example a table has rows a,b,c and cols 1,2,3. Each row is formed by
> a
> loop, but I don't necessarily have values for each cell- the row is
> determined by one of the fields- (in the example "y" specifies the
> row)
>
> how do I start the loop over in the middle of the loop?
>
> specifcally:
> dbrs.MoveFirst()
> do while not dbrs.eof
> dbrs. Move(0)
> x = dbrs("x")
> y = dbrs("y")
>
> %>
> <tr>
> <% if x = "a1" then
> response.write("<td>" & value1 & "</td>")
> else
> response.write("<td></td>")
> end if
> dbrs.MoveNext
> y2 = dbrs("y")
> if y2 = y1 then
> 'continue with code
> else
> response.write("<td colspan=2></td></tr>")
> ' ? goto beginning of loop
> end if
> %>
> <td>
> <% if x = "a2" then
> response.write("<td>" & value2 & "</td>")
> else
> response.write("<td></td>")
> end if
> dbrs.MoveNext
> y2 = dbrs("y")
> if y2 = y1 then
> 'continue with code
> else
> response.write("<td></td></tr>")
> ' ? goto beginning of loop
> end if
> %>
> <td>
> <% if x = "a3" then
> response.write("<td>" & value3 & "</td>")
> else
> response.write("<td></td>")
> end if
> %>
> </tr>
> <%
> dbrs.MoveNext
> loop
> %>
>
> Thanks, Amanda
>
>
> *** Sent via Developersdex http://www.developersdex.com ***



Sponsored Links







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

Copyright 2008 codecomments.com