The program takes the users information in from text boxes from another part of the program and writes the information into a text file. So when the user clicks on this button it will display all the people that have entered in their names. I want to sort their last names alphabetticaly.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListCustomers.Click
'Variables
Dim sr As StreamReader = File.OpenText("test.txt")
Dim fmtStr As String = "{0,-15}{1,10} {2,10} {3,5}"
Dim strLastName, strFirstName As String
Dim intZip, intID As Integer
'Output header for previous users
lstOutput.Items.Clear()
lstOutput.Items.Add(String.Format(fmtStr, "Last Name", "First Name", "Zip Code", "ID #"))
lstOutput.Items.Add("")
'Read previous users information
Do Until sr.Peek = -1
strLastName = (sr.ReadLine)
strFirstName = (sr.ReadLine)
intZip = (sr.ReadLine)
intID = (sr.ReadLine)
lstOutput.Items.Add(String.Format(fmtStr, strLastName, strFirstName, intZip, intID))
Loop
sr.Close()
End Sub

New Topic/Question
Reply




MultiQuote





|