Private Structure Person
<VBFixedString(15)> Public FirstName as String
<VBFixedString(15)> Public LastName as String
End Structure
Public P as Person
Public LastRecord as Integer ' Integer replaced long in .NET
Public RecLength as Integer
Private Sub Save()
RecLength = Len(P)
P.FirstName = Me.textname.Text
P.LastName = Me.LastName.Text
Dim sw as New IO.StreamWriter("Path\MYFILE.DAT", True) 'The true means to append the file, not overwrite it.
sw.Write(P.FirstName & vbTab & P.LastName & vbNewLine)
sw.Close()
sw = Nothing
Me.ListBox1.Items.Clear()
LoadList()
End Sub
Private Sub LoadList()
Dim sr as New IO.StreamReader("Path\MYFILE.DAT")
Dim line, vals() as String
Do
line = sr.ReadLine
If line is Nothing Then Exit Do
vals = line.Split(vbTab)
Me.ListBox1.Items.Add(vals(0).ToString)
Loop
sr.Close()
sr = Nothing
End Sub