<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi all, I use a slightly different approach to parsing the single array into multiple arrays using a for next loop with a step counter.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Philip Pike<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Director of ICT<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Bacchus Marsh Grammar<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Sth Maddingley Rd.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Bacchus Marsh 3340<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Ph 03 53664800<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>fax 03 53664850<o:p></o:p></span></p></div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> sofdev-bounces@edulists.com.au [mailto:sofdev-bounces@edulists.com.au] <b>On Behalf Of </b>Travis Parker<br><b>Sent:</b> Thursday, 12 May 2011 9:49 AM<br><b>To:</b> Year 12 Software Development Teachers' Mailing List<br><b>Subject:</b> Re: [Year 12 SofDev] Reading and Writing text data files in VB2010<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Wow Damien thanks for the speedy response – That’s exactly what I need! <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I’ll try to get my application working and do a bit more practice working through the VITTA one as well (Jackson’s pond emporium – Mine is based around that structure) then see where we end up. I was going to use a 2D array to store all of what you have as <i>Values</i> so I could read them all into the same place and sort by the priority (Last value in each line – 1, 2 or 3) but I can see 2D arrays are part of U4O1 not U3O2 so will get around that and send my (Hopefully fully functional) solution through!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks again<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Trav<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><a name="_MailEndCompose"></a><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> sofdev-bounces@edulists.com.au [mailto:sofdev-bounces@edulists.com.au] <b>On Behalf Of </b>ATKINSON-BUCK, Damien<br><b>Sent:</b> Thursday, 12 May 2011 9:38 AM<br><b>To:</b> Year 12 Software Development Teachers' Mailing List<br><b>Subject:</b> Re: [Year 12 SofDev] Reading and Writing text data files in VB2010<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Mark, thanks for another great tutorial. Building on Marks work might be what you need Trav<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-bottom:solid windowtext 1.0pt;padding:0cm 0cm 1.0pt 0cm'><p class=MsoNormal><span style='font-size:10.0pt'>One of the more common uses of reading a text file is to read various values of a CSV (comma separated values) file, where individual items (think fields of a flat file database) are read into an array for future processing. Visual Basic has a very nice easy way to do this using the Split function. Imagine that you have the above text file with the following data copied from this week’s Aria charts;<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>1,WE RUN THE NIGHT,DJ Havana Brown,ISL/UMA<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>2,FROM THE MUSIC,The Potbelleez,VIC/UMA<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>3,WHAT HAPPENED TO USJessica Mauboy Feat. Jay Sean,SME<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>4,DANCE WITH ME,Justice Crew Feat. Flo Rida,SME<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>5,FRIDAY TO SUNDAY,Justice Crew,SME<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>6,MAYBE,Sick Puppies,VIR/EMI<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p> </o:p></span></p></div><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> <span style='color:blue'>Dim</span> TextFile <span style='color:blue'>As</span> <span style='color:blue'>New</span> System.IO.StreamReader(<span style='color:#A31515'>"</span></span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>u:\albums.txt</span><span style='font-size:9.5pt;font-family:Consolas;color:#A31515'> "</span><span style='font-size:9.5pt;font-family:Consolas'>)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> <span style='color:blue'>Dim</span> strAlbumName <span style='color:blue'>As</span> <span style='color:blue'>String</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> strAlbumName = TextFile.ReadLine()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> <span style='color:blue'>Do</span> <span style='color:blue'>Until</span> strAlbumName <span style='color:blue'>Is</span> <span style='color:blue'>Nothing</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> <span style='color:green'>'lstAlbums.Items.Add(strAlbumName)</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> <span style='color:blue'>Dim</span> Values() <span style='color:blue'>As</span> <span style='color:blue'>String</span> = Split(strAlbumName, <span style='color:#A31515'>","</span>)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> strAlbumName = TextFile.ReadLine()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> <span style='color:green'>' Values(0) now contains first column value,</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> <span style='color:green'>' Values(1) contains second column, etc.<o:p></o:p></span></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> <span style='color:blue'>Loop</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> TextFile.Close()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'> TextFile.Dispose()<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Cheers<o:p></o:p></span></p><div><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=696 style='width:522.0pt'><tr><td style='padding:0cm 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>Damien Atkinson-Buck</span></b><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><br>Member of Academic Staff (Secondary)</span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><div><div><div><div class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><hr size=2 width=500 style='width:375.0pt' align=left></span></div></div></div></div></td></tr><tr><td style='padding:0cm 0cm 0cm 0cm'><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=696 style='width:522.0pt'><tr><td width=164 style='width:123.0pt;padding:0cm 0cm 0cm 0cm'><p class=MsoNormal><a href="http://myivanhoe.net/"><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";text-decoration:none'><img border=0 width=200 height=64 id="Picture_x0020_2" src="cid:image001.jpg@01CC108E.FFA36300" alt="Description: Description: cid:image002.jpg@01CA7D93.5FFD22D0"></span></a><span style='font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p></td><td width=5 style='width:3.75pt;padding:0cm 0cm 0cm 0cm'><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><span style='font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p></td><td style='padding:0cm 0cm 0cm 0cm'><p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif";color:#1F497D'>PO BOX 91 The Ridgeway, Ivanhoe, Victoria 3079 Australia<br>Telephone +61 3 9490 3848 Facsimile +61 3 9490 3490<br></span><a href="mailto:damien.atkinson-buck@ivanhoe.com.au"><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'>mailto:damien.atkinson-buck@ivanhoe.com.au</span></a><span style='font-size:7.5pt;font-family:"Arial","sans-serif";color:#1F497D'><br></span><a href="http://myivanhoe.net/"><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'>http://myivanhoe.net</span></a><span style='font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p></td></tr></table></td></tr></table><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p></div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Travis Parker [mailto:Travis.Parker@beaconhills.vic.edu.au] <br><b>Sent:</b> Thursday, 12 May 2011 9:26 AM<br><b>To:</b> Year 12 Software Development Teachers' Mailing List<br><b>Subject:</b> Re: [Year 12 SofDev] Reading and Writing text data files in VB2010<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks for that Mark. I have been using something similar with my students, particularly as the SAC I have written includes reading from a text file (A prototype helpdesk, including type of job, computer, priority, etc) and creating a new text file with jobs for the techies in a prioritised order.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>One thing I was wondering though, does anyone have anything good on reading comma separated text files? All the programs I have gotten my students to create read them a line at a time, but I would ideally like to see something like this line - </span>tim.cox, hardware, 12, ps40, 2 <span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>read into arrays. So I would have a “Name”, “Issue”, “Computer_Number”, “Room_Number”, “Priority” or something like that. I’m fine with the arrays, but how would I read it in word at a time (i.e. Between commas” rather than line at a time?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>With many thanks for a first year SD newbie……<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Trav<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> sofdev-bounces@edulists.com.au [mailto:sofdev-bounces@edulists.com.au] <b>On Behalf Of </b>Mark KELLY<br><b>Sent:</b> Wednesday, 11 May 2011 12:45 PM<br><b>To:</b> Year 12 Software Development Teachers' Mailing List<br><b>Subject:</b> [Year 12 SofDev] Reading and Writing text data files in VB2010<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi, you paragons of pedagogy. I've been putting off teaching my kids how to read and write text data files in VB but having investigated today, it's not really more difficult than the days of VB6 with OPEN "file" FOR INPUT AS 1 ... INPUT #1, data.<br><br>I've attached an adapted tutorial on reading and writing text files with a task involving reading and writing a preferences file (with solution).<br><br>Once your kids can do data files, it greatly opens the scope for populating and playing with really large arrays and makes loops meaningful. <br><br>I remember how excited I was when I first discovered text files decades ago - it was like finding mum's car keys. My programming world blossomed from that point.<br clear=all><br>-- <br>Mark Kelly<br>Manager of ICT, Reporting, IT Learning Area<br>McKinnon Secondary College<br>McKinnon Rd McKinnon 3204, Victoria, Australia<br>Direct line / Voicemail: +613 8520 9085, Fax +613 9578 9253<br><a href="mailto:kel@mckinnonsc.vic.edu.au" target="_blank">kel@mckinnonsc.vic.edu.au</a><br>VCE IT Lecture Notes: <a href="http://vceit.com" target="_blank">http://vceit.com</a><br>Moderator: IT Applications Edulist<br><br>Want a good time? Call 0112358. Ask for Mr Fibonacci.<o:p></o:p></p><p class=MsoNormal><br><br><br><br>Privacy, Virus and Copyright Warning<br><br>The information contained in this electronic message (e-mail), and any files transmitted with it:<br><br>* is intended for the named recipients only. If you have received this in error, please advise the sender and delete it and any copies immediately;<br>* Any personal information in this email must be used in accordance with the Privacy Act 1988 and this always applies even if it has been sent to you in error.<br>* represents the views of the sender and does not necessarily represent the views or formal advice of Ivanhoe Grammar School;<br>* may be subject to Copyright, so no further use should be made of it without the author's permission.<br><br>The School does not represent or warrant that the email or any files attached do not contain errors or are free from computer viruses or other defects nor does it accept responsibility for any loss or damage resulting directly or indirectly from the use of the email or any attached files. <o:p></o:p></p></div></body></html>