<%@Import Namespace="System.IO"%> <script language="vb" runat="server"> Sub page_load(Sender As Object,e As EventArgs) Dim filetoread as string filetoread=server.mappath("Output.txt") dim filestream as StreamReader filestream = File.Opentext(filetoread) Dim read as String=fileStream.ReadToEnd() dim str1, s as string dim i,k as integer dim str1, str2(), s as string dim i,k as integer for k=0 to (read.count)-1 str1=read.item(k) str2=str1.split("~") dim r As New TableRow() dim c11 As New TableCell() dim chkbox11 as new checkbox c11.Controls.Add(chkbox11) r.Cells.Add(c11) for i=0 to 5 dim c As New TableCell() c.Controls.Add(New LiteralContro(str2(i))) r.Cells.Add(c) next table.Rows.Add(r) next end sub </script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Contact Us</title> </head> <body> <p align="center"> <input name="imageField" type="image" src="image/bimicologo.jpg" > </p> <h2 align="center"><strong></strong></h2> <hr> <form runat="server"> <table border="0" width="100%"> <tr> <td width="15%" valign="top" rowspan="3"><a href="home_page.aspx">Home Page</a></br> <b><a href="active_message.aspx">Active Message</a></b></br> <a href="search.aspx">Search</a></br> <a href="contact_us.aspx">Contact Us</a> </td> <td width="100%"> <h4>Customer Messages</h4> <asp:label id="submit_msg" runat="server"/> <asp:table id="table" runat="server" width="100%" border="1"> <asp:TableRow> <asp:TableheaderCell width="6%" halign="center">Remove</asp:TableheaderCell> <asp:TableheaderCell width="15%">Urgency Level</asp:TableheaderCell> <asp:TableheaderCell width="10%">Name</asp:TableheaderCell> <asp:TableheaderCell width="15%">e-mail</asp:TableheaderCell> <asp:TableheaderCell width="10%">Day Phone</asp:TableheaderCell> <asp:TableheaderCell width="10%">Mobile</asp:TableheaderCell> <asp:TableheaderCell width="50%">Message</asp:TableheaderCell> </asp:TableRow> </asp:table> </td> </tr> <tr> <td align="center"><asp:button id="btnremove" runat="server" text="Remove message" /></td> </tr> </table> </form> </body> </html> Code (asp): All i want to do is read the text file , split it , and display it in the Web page! However , i have some trouble with it , can any one help me plz!
try this code to read the file line by line: Dim filetoread as string filetoread=server.mappath("Output.txt") Dim sr as New StreamReader(filetoread ) Dim line as String = sr.ReadLine() Do While Not line is Nothing Response.Write(line & "<br>") line = sr.ReadLine() Loop Code (asp):
Error: Index was Outside of the Bounds of the Array. Please take a look at my attachment , they will explaint what i want to do! thank!