• 0

Exporting Names to txt file


Question

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

  • 0

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.