pnd2051 Posted September 10, 2009 Share Posted September 10, 2009 im creating a program to record results of teams over a season and want to add the names of teams to a text file which can be loaded by the program, i've created the file extension i just don't know how to add the names to the file Any Help would be greatly appreciated :) Link to comment Share on other sites More sharing options...
0 +Majesticmerc MVC Posted September 10, 2009 MVC Share Posted September 10, 2009 What language are you programming in? Link to comment Share on other sites More sharing options...
0 pnd2051 Posted September 10, 2009 Author Share Posted September 10, 2009 Sorry Forgot to mention its in Visual Basic Link to comment Share on other sites More sharing options...
0 Nick Brunt Posted September 10, 2009 Share Posted September 10, 2009 You should try using ini files, they're much better and simpler to use once you have set them up. (http://www.tek-tips.com/faqs.cfm?fid=3955) You can have sections with different data in. E.g. each team could have its own section with data such as Number of Wins and Number of Loses. Or even better, use a database. Link to comment Share on other sites More sharing options...
0 +Majesticmerc MVC Posted September 11, 2009 MVC Share Posted September 11, 2009 The following assumes that you're using VB.NET, not VB6. First off, you can make your file like this... Team 1 Team 2 Team 3 Team 4 ... where each teams name is on its own line. Then to read in the file you could simply do this... Dim sr As New System.IO.StreamReader("Myfile.ext") Dim teamNames As String() = sr.ReadToEnd().Split(New Char() {ControlChars.Cr, ControlChars.Lf}, StringSplitOptions.RemoveEmptyEntries) Provided I wrote that correctly, if you replace "MyFile.ext" with the name of the file containing your team names, it will load the names of the teams into the array of strings. Hope this helps. Link to comment Share on other sites More sharing options...
Question
pnd2051
im creating a program to record results of teams over a season and want to add the names of teams to a text file which can be loaded by the program, i've created the file extension i just don't know how to add the names to the file
Any Help would be greatly appreciated :)
Link to comment
Share on other sites
4 answers to this question
Recommended Posts