Reading text file VB.NET

  • Thread starter Thread starter 70CC07
  • Start date Start date
7

70CC07

Guest
import a txt file and its contents and export it to another file. -- I have already completed this.

The output file should add a tab followed by a random number between 1 and 100 after each name.

example:

Ann 30

Mike 10

Edward 22

When the user clicks a button read in the file you created and give the following:

number of rows (displayed in label)

avg of the numbers (displayed in label)

highest number and who had it (displayed in label)

So im really just looking for guidance on how to add a tab after the name and code the label outputs. Any guidance is greatly appreciated. Thanks. Below is the first part of what i have so far.



Private Sub btnGenerateFile_Click(sender As Object, e As EventArgs) Handles btnGenerateFile.Click
Dim sw As StreamWriter
Dim sr As StreamReader
Dim s As String
Dim i As Integer
Dim T As String
Dim inputfile As String
Dim outputfile As String

inputfile = Application.StartupPath & "\Names.txt"
outputfile = Application.StartupPath & "\output.txt"

sw = File.CreateText(outputfile)
sr = File.OpenText(inputfile)

Do While sr.Peek > -1
s = sr.ReadLine
T = s.ToUpper
sw.WriteLine(T)
Loop
sr.Close()
sw.Close()

Continue reading...
 
Back
Top