I am making a windows form in vb.net that needs to read form a text file and insert the text as objects when the form loads . The textboxes are as follow
TxtJobtitle.Text
TxtSalary.Text
TxtFullname.Text
TxtAdd1.Text
TxtAdd2.Text
TxtTown.Text
TxtCounty.Text
TxtPostcode.Text
TxtPhone.Text
TxtEmail.Text
i have this code to save it to the text file (not sure if its correct)
Private Sub CmdSaveall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSaveall.Click
Dim sw As New StreamWriter("Staff.txt")
counter = 0
While counter < collection.Length
sw.WriteLine(collection(counter).Jobtitle)
sw.WriteLine(collection(counter).Salary)
sw.WriteLine(collection(counter).Fullname)
sw.WriteLine(collection(counter).Add1)
sw.WriteLine(collection(counter).Add2)
sw.WriteLine(collection(counter).Town)
sw.WriteLine(collection(counter).County)
sw.WriteLine(collection(counter).Postcode)
sw.WriteLine(collection(counter).Phone)
sw.WriteLine(collection(counter).Email)
counter += 1
End While
sw.Close()
So what would be the best way to do this been trying to do it for 5 hours now
TxtJobtitle.Text
TxtSalary.Text
TxtFullname.Text
TxtAdd1.Text
TxtAdd2.Text
TxtTown.Text
TxtCounty.Text
TxtPostcode.Text
TxtPhone.Text
TxtEmail.Text
i have this code to save it to the text file (not sure if its correct)
Private Sub CmdSaveall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSaveall.Click
Dim sw As New StreamWriter("Staff.txt")
counter = 0
While counter < collection.Length
sw.WriteLine(collection(counter).Jobtitle)
sw.WriteLine(collection(counter).Salary)
sw.WriteLine(collection(counter).Fullname)
sw.WriteLine(collection(counter).Add1)
sw.WriteLine(collection(counter).Add2)
sw.WriteLine(collection(counter).Town)
sw.WriteLine(collection(counter).County)
sw.WriteLine(collection(counter).Postcode)
sw.WriteLine(collection(counter).Phone)
sw.WriteLine(collection(counter).Email)
counter += 1
End While
sw.Close()
So what would be the best way to do this been trying to do it for 5 hours now