[Year 12 SofDev] Text Files in VB.NET
Shane Dawson
shaned at sjc.vic.edu.au
Fri Apr 27 12:41:16 EST 2012
Here is one way, using the .split element that allows you to designate what the splitting character is.
Private Sub Exchange_Calculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'opens the selected file
Dim openFile As StreamReader = File.OpenText("rates.txt")
'each line of the rates.txt file contains the following information as a csv file
'strcountry is each country, stored as a seperate element in rates.txt
'strcurrency is each country, stored as a seperate element in rates.txt
'strrate is each rate, stored as a seperate element in rates.txt
Dim C As Integer = 0
Do While openFile.Peek <> -1
'there are 5 students in the the file.
strexchange = openFile.ReadLine()
'Each element of StrSplit is gotten from whatever is read, seperated
'by a comma
strsplit = strexchange.Split(",")
' Load split text into an array
strarraysplit(0, C) = strsplit(0)
strarraysplit(1, C) = strsplit(1)
strarraysplit(2, C) = strsplit(2)
strarraysplit(3, C) = strsplit(3)
C = C + 1
Loop
'close the file
openFile.Close()
'load lists
For J As Integer = 0 To C - 1
lstCountry.Items.Add(strarraysplit(0, J))
lstCurrency.Items.Add(strarraysplit(1, J))
lstRate.Items.Add(strarraysplit(2, J))
lstSymbol.Items.Add(strarraysplit(3, J))
Next
End Sub
From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au] On Behalf Of PIKE Philip
Sent: Friday, 27 April 2012 9:39 AM
To: Year 12 Software Development Teachers' Mailing List
Subject: Re: [Year 12 SofDev] Text Files in VB.NET
Yet another method.
My document shows how to break up a line of text containing a number of fields into different arrays. I'd be happy to hear of a better way to do this.
Philip Pike
Director of ICT
Bacchus Marsh Grammar
Sth Maddingley Rd
Bacchus Marsh 3340
Ph 5366 4893
Fax 5366 4850
Email: pikep at bmg.vic.edu.au<mailto:pikep at bmg.vic.edu.au>
From: sofdev-bounces at edulists.com.au<mailto:sofdev-bounces at edulists.com.au> [mailto:sofdev-bounces at edulists.com.au]<mailto:[mailto:sofdev-bounces at edulists.com.au]> On Behalf Of Mark KELLY
Sent: Thursday, 26 April 2012 5:13 PM
To: Year 12 Software Development Teachers' Mailing List
Subject: Re: [Year 12 SofDev] Text Files in VB.NET
There's more than one way to do it. I tend to use the older-fashioned method, 'cos I an old-fashioned girl :-)
See attached - they might help.
On 26 April 2012 15:31, Ben Hines <b.hines at ccg.vic.edu.au<mailto:b.hines at ccg.vic.edu.au>> wrote:
Hey guys,
I'm starting to look at outputting information to a text file and inputting information from a text file in VB.NET<http://VB.NET>.
I was wondering if anyone has a simple example that shows how to do this?
Thanks
Mr Ben Hines
VCE Maths/ICT Teacher
Senior School Campus - Christian College Geelong
*(03) 52411577<tel:%2803%29%2052411577> (ext. 180)
This e-mail is intended for the use of the named individual or entity and may contain confidential and privileged information. Any dissemination, distribution or copying by anyone other than the intended recipient of this e-mail is strictly prohibited. If this e-mail has been received in error, then please notify Christian College or the author of this email immediately and destroy the original message. We have made every attempt to ensure this e-mail message is free from computer viruses however the attached files are provided on the basis that the user assumes all responsibility for use of the material transmitted. Views, opinions, etc. expressed reflect those of the author and not Christian College nor its associated companies and campuses which includes Eden Quality Services Pty Ltd.
________________________________
Message protected by MailGuard: e-mail anti-virus, anti-spam and content filtering.
http://www.mailguard.com.au
_______________________________________________
http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority and
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
http://www.vitta.org.au - VITTA Victorian Information Technology Teachers Association Inc
http://www.swinburne.edu.au/ict/schools - Swinburne University
--
Mark Kelly
Manager of ICT, Reporting, IT Learning Area
McKinnon Secondary College
McKinnon Rd McKinnon 3204, Victoria, Australia
Direct line / Voicemail: +613 8520 9085, Fax +613 9578 9253
kel at mckinnonsc.vic.edu.au<mailto:kel at mckinnonsc.vic.edu.au> (don't use my Edumail account!)
VCE IT Lecture Notes: http://vceit.com
Moderator: IT Applications Edulist
--
An E-flat, a C, and a G go into a bar. The bartender says, "I'm sorry, but I can't serve minors."
________________________________
PRIVATE & CONFIDENTIAL
The content of this e-mail and any attachments may be private and confidential, intended only for use of the individual or entity named. If you are not the intended recipient of this message you must not read, forward, print, copy, disclose, use or store in any way the information this e-mail or any attachment contains.
If you are not the intended recipient, please notify the sender immediately and delete or destroy all copies of this e-mail and any attachments.
Our organisation respects the privacy of individuals. For a copy of our privacy policy please go to our website or contact us.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20120427/2ea64871/attachment-0001.html
More information about the sofdev
mailing list