<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Re: [Year 12 SofDev] Working with CSV text files</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.6129" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello Shane</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'm curious to know why you've used</FONT></DIV>
<DIV> Do While Openfile.Peek <>
-1 'read from file until end of
file<BR></DIV>
<DIV><FONT face=Arial size=2>rather than</FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face="Times New Roman" size=3>
Do While Not Openfile.EndOfStream 'read from file
until end of file</FONT><BR></FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV></FONT>
<DIV><FONT face=Arial size=2>Regards</FONT></DIV>
<DIV><FONT face=Arial size=2>Robert T-A</DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=shortell@get2me.net href="mailto:shortell@get2me.net">Andrew
Shortell</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=sofdev@edulists.com.au
href="mailto:sofdev@edulists.com.au">Year 12 Software Development Teachers'
Mailing List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, August 26, 2011 10:26
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Year 12 SofDev] Working
with CSV text files</DIV>
<DIV><BR></DIV><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 “” then that finds eof. There are multiple
ways.<BR>I do like Shane’s method – 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 9470
3215<BR><BR><BR><BR>On 26/08/11 10:17 AM, "Mark KELLY" <<A
href="mailto:kel@mckinnonsc.vic.edu.au">kel@mckinnonsc.vic.edu.au</A>>
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 <<A
href="shaned@sjc.vic.edu.au">shaned@sjc.vic.edu.au</A>>
wrote:<BR></SPAN></FONT>
<BLOCKQUOTE><FONT face="Calibri, Verdana, Helvetica, Arial"><SPAN
style="FONT-SIZE: 11pt">If you are using the str.split(",") 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>
'cmbDish.Items.Add("") 'add a first line that is empty in
combobox<BR> Dim C As Integer = 0 'count
for dishes<BR> Dim Openfile As
StreamReader = File.OpenText(TextFile) 'open text file for the selected
section of the menu<BR> Do While
Openfile.Peek <> -1 'read from file until end of
file<BR> strDish =
Openfile.ReadLine() 'read a line from the text file and store into a
string<BR> strsplit =
strDish.Split(",") 'split the stored line into dish and
cost<BR>
cmbDish.Items.Add(strsplit(0)) 'add the dish name to the the dish
combobox<BR> strDishCost(C)
= Val(strsplit(1)) 'store the dish cost into an array<BR>
C = C + 1 'add one to the dish
count<BR> Loop<BR>
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 "Hi-scores table"<BR>in his great
"VB.net for education" 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 "@" symbol and a ".com" 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>
<P>
<HR>
<P></P>_______________________________________________<BR>http://www.edulists.com.au
- FAQ, Subscribe, Unsubscribe<BR>IT Software Development Mailing List kindly
supported by<BR>http://www.vcaa.vic.edu.au - Victorian Curriculum and
Assessment Authority
and<BR>http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
<BR>http://www.vitta.org.au - VITTA Victorian Information Technology
Teachers Association Inc</BLOCKQUOTE></BODY></HTML>