This is a multipart message in MIME format.
--=_alternative 0064CE658025711B_=
Content-Type: text/plain; charset="us-ascii"

I'm trying to loop through a text file that contains losts of surnames and
produce a table with all the A surnames in row 1, B surnames in row 2 etc
but I'm getting a bit stuck, I keep ending up with a table with 24 rows
and only the surnames begining with A in all the rows. I realise I need
to add another loop in somewhere to produce the table row and then move
onto the next letter but i can't get my head round it at the moment.

Here's my code:

<table border="1" width="520" align="center">
<%
for i = 65 to 89
do while objTextFile.AtEndOfStream <> True
strTextFileLine = objTextFile.ReadLine
if Left(strTextFileLine, 1) = i then
strSurnameList = strSurnameList &
strTextFileLine & ","
end if
Loop
strMain2 = "<tr><td>" & strSurnameList & "</td></tr>"
response.write strMain2
next
%>
</table>
--=_alternative 0064CE658025711B_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">I'm trying to loop through a text file that contains losts of surnames and produce a table with all the A surnames in row 1, B surnames in row 2 etc but I'm getting a bit stuck, I keep ending up with a table with 24 rows and only the surnames begining with A in all the rows. &nbsp;I realise I need to add another loop in somewhere to produce the table row and then move onto the next letter but i can't get my head round it at the moment.</font>
<br>
<br><font size=2 face="sans-serif">Here's my code:</font>
<br>
<br><font size=2 face="sans-serif">&lt;table border=&quot;1&quot; width=&quot;520&quot; align=&quot;center&quot;&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &lt;%</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; for i = 65 to 89</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do while objTextFile.AtEndOfStream &lt;&gt; True</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strTextFileLine = objTextFile.ReadLine</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Left(strTextFileLine, 1) = i then</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strSurnameList = strSurnameList &amp; strTextFileLine &amp; &quot;,&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Loop</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strMain2 = &quot;&lt;tr&gt;&lt;td&gt;&quot; &amp; strSurnameList &nbsp;&amp; &quot;&lt;/td&gt;&lt;/tr&gt;&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.write strMain2</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; next</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; %&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/table&gt;</font>
--=_alternative 0064CE658025711B_=--

Re: loops and tables by Steven

Steven
Mon Feb 20 12:44:34 CST 2006

How is the file containing the names setup?

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

<helen@postle.co.uk> wrote in message
news:fOnKf.25911$DM.13953@fe3.news.blueyonder.co.uk...
> I'm trying to loop through a text file that contains losts of surnames and
> produce a table with all the A surnames in row 1, B surnames in row 2 etc
> but I'm getting a bit stuck, I keep ending up with a table with 24 rows
> and only the surnames begining with A in all the rows. I realise I need
> to add another loop in somewhere to produce the table row and then move
> onto the next letter but i can't get my head round it at the moment.
>
> Here's my code:
>
> <table border="1" width="520" align="center">
> <%
> for i = 65 to 89
> do while objTextFile.AtEndOfStream <> True
> strTextFileLine = objTextFile.ReadLine
> if Left(strTextFileLine, 1) = i then
> strSurnameList = strSurnameList &
> strTextFileLine & ","
> end if
> Loop
> strMain2 = "<tr><td>" & strSurnameList & "</td></tr>"
> response.write strMain2
> next
> %>
> </table>



Re: loops and tables by \

\
Mon Feb 20 13:37:38 CST 2006

> I'm trying to loop through a text file that contains losts of surnames and
> produce a table with all the A surnames in row 1, B surnames in row 2 etc
> but I'm getting a bit stuck, I keep ending up with a table with 24 rows
> and only the surnames begining with A in all the rows. I realise I need
> to add another loop in somewhere to produce the table row and then move
> onto the next letter but i can't get my head round it at the moment.

Assuming all the names, A to Z, are in a single file, this should work (they
don't have to be sorted):
'------------------------------------------------------------
<table border="1" width="520" align="center">
<%
dim rows(26)

do until objTextFile.AtEndOfStream
strTextFileLine = objTextFile.ReadLine
n=asc(ucase(Left(strTextFileLine, 1)))-64
rows(n)=rows(n) & "," & strTextFileLine
loop

for i = 1 to 26
if len(rows(i)) then
response.write "<tr><td>" & rows(i) & "</td></tr>"
end if
next
%>
</table>
'---------------------------------------------------------------
--
Crash
"The pursuit of perfection often impedes improvement." -- George Will