<HTML>
<HEAD>
<TITLE>Re: [Year 12 SofDev] Working with CSV text files</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>If you read ahead (so prior to entry and at end of while loop) and test for null or &#8220;&#8221; then that finds eof. There are multiple ways.<BR>
I do like Shane&#8217;s method &#8211; more elegant<BR>
Andrew<BR>
-- <BR>
</SPAN></FONT><FONT SIZE="4"><FONT FACE="Apple Casual"><SPAN STYLE='font-size:14pt'>Andrew Shortell<BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
<a href="mailto:shortell@get2me.net">mailto:shortell@get2me.net</a> <BR>
Heidelberg Teaching Unit<BR>
Ph 9470 3403<BR>
Fax &nbsp;9470 3215<BR>
<BR>
<BR>
<BR>
On 26/08/11 10:17 AM, &quot;Mark KELLY&quot; &lt;<a href="kel@mckinnonsc.vic.edu.au">kel@mckinnonsc.vic.edu.au</a>&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Cool. I was wondering how to test for EOF using Streamreader. I ended up using a different file access system via file handles (as it was in the good ol' VB6 and even QB4.5 days).<BR>
<BR>
On 26 August 2011 09:52, Shane Dawson &lt;<a href="shaned@sjc.vic.edu.au">shaned@sjc.vic.edu.au</a>&gt; wrote:<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>If you are using the str.split(&quot;,&quot;) function in VB.Net and have an array that stores how many columns of data you have eg. Splitstring(50,4) (50 rows, 4 coulmns) you can then read in each csv line and store it as separate elements in the array.<BR>
<BR>
You can then use this to populate the relevant text boxes.<BR>
<BR>
cmbDish.Items.Clear() 'clear the combobox containing dishes<BR>
&nbsp;       'cmbDish.Items.Add(&quot;&quot;) 'add a first line that is empty in combobox<BR>
&nbsp;       Dim C As Integer = 0 'count for dishes<BR>
&nbsp;       Dim Openfile As StreamReader = File.OpenText(TextFile) 'open text file for the selected section of the menu<BR>
&nbsp;       Do While Openfile.Peek &lt;&gt; -1 'read from file until end of file<BR>
&nbsp;           strDish = Openfile.ReadLine() 'read a line from the text file and store into a string<BR>
&nbsp;           strsplit = strDish.Split(&quot;,&quot;) 'split the stored line into dish and cost<BR>
&nbsp;           cmbDish.Items.Add(strsplit(0)) 'add the dish name to the the dish combobox<BR>
&nbsp;           strDishCost(C) = Val(strsplit(1)) 'store the dish cost into an array<BR>
&nbsp;           C = C + 1 'add one to the dish count<BR>
&nbsp;       Loop<BR>
&nbsp;       Openfile.Close()<BR>
<BR>
-----Original Message-----<BR>
From: <a href="sofdev-bounces@edulists.com.au">sofdev-bounces@edulists.com.au</a> [<a href="mailto:sofdev-bounces@edulists.com.au">mailto:sofdev-bounces@edulists.com.au</a>] On Behalf Of Travis Parker<BR>
Sent: Friday, 26 August 2011 9:41 AM<BR>
To: Year 12 Software Development Teachers' Mailing List<BR>
Subject: [Year 12 SofDev] Working with CSV text files<BR>
<BR>
Dear All,<BR>
<BR>
I am halfway through a program with my Year 12 SD class that writes to a text file (Comma separated) and allows them to add and delete records from it (Using similar techniques to Adrian Janson's &quot;Hi-scores table&quot;<BR>
in his great &quot;VB.net for education&quot; book). I have included many validation techniques, including range checking for a person's age (They must be a uni student so this is a bit controversial, particularly about mature age students!), existence checking for names, and data type checking for numbers (They must enter numbers only for phone numbers - Not necessarily correct in real life but just using it as an example).<BR>
<BR>
I have also created a funky little program that validates email addresses (Attached as a zip file). It makes sure that it follows a logical structure, including containing the &quot;@&quot; symbol and a &quot;.com&quot; or equivalent at the end. Students incorporate this code into their validation of user entries as well.<BR>
<BR>
One thing that I am doing at the moment though is looking at editing individual records. I have tried numerous methods using past code for CSV files, and ideally I would have the user select a record (Displayed in a listbox) and click btnEdit, then the program would read each field back into the original textbox that it was entered (i.e. Their name is read back into the text property of txtName). So far all I can manage is having it read the entire text file back into a multiline textbox and allow the user to edit it there, then save or discard the changes. This works, but is more prone to human error and I would like a better way of doing things.<BR>
<BR>
If anyone can help or is facing a similar issue it would be great if you could give me some idea of what to do here.<BR>
<BR>
Many thanks<BR>
<BR>
Trav<BR>
<BR>
<BR>
<BR>
_______________________________________________<BR>
<a href="http://www.edulists.com.au">http://www.edulists.com.au</a> - FAQ, Subscribe, Unsubscribe<BR>
IT Software Development Mailing List kindly supported by<BR>
<a href="http://www.vcaa.vic.edu.au">http://www.vcaa.vic.edu.au</a> - Victorian Curriculum and Assessment Authority and<BR>
<a href="http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html">http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html</a><BR>
<a href="http://www.vitta.org.au">http://www.vitta.org.au</a>  - VITTA Victorian Information Technology Teachers Association Inc<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
-- <BR>
</SPAN></FONT>
</BODY>
</HTML>