Click to See Complete Forum and Search --> : Loop adding a BR evey 5 counts
Hi there.
I have a loop that run and I want to add the <br> tage each time the i equals 5,10,15,20 and so on...
How can I do it?
Thanks!
lmf232s
12-12-2004, 01:09 AM
for i = 1 to 25
if i mod 5 then
'execute your code
else
Response.Write "<br>"
end if
Next
newmediaguy
12-13-2004, 07:40 AM
Hi I would take a slightly different approach...
<%
'Loop through and count for condition
Dim TopVal
For i = 1 to TopVal
j = j + 1
If j mod 5 = 0 then Response.write("<br>")
Next
%>
This way all you need to do is pass in the total number and this will work with minimal change etc
just a thought.
Thanks
Glen
Conception | Execution
scragar
12-13-2004, 07:44 AM
why use j = j + 1? you could use i to the same effect within the code:
<%
Dim TopVal
For i = 1 to TopVal
If i mod 5 = 0 then Response.write("<br>")
Next
%>
newmediaguy
12-13-2004, 07:46 AM
doh...
I missesd that one....must take my time in future.
Thanks
Glen
scragar
12-13-2004, 08:06 AM
with your code though I could proberly cut it down a little more:
<%
Dim TopVal
dim i
i = 0
while(i <= TopVal / 5)
Responce.write("<br>")
i = i + 1
wend
%>
Note: although it may look longer it actualy takes up about 1/4 of the time...