Private Sub btnInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInput.Click
oneitem.Forename = txtForename.Text
oneitem.Surname = txtSurname.Text
oneitem.Age = txtAge.Text
FileClose(1)
FileOpen(1, Filename, OpenMode.Random, , , Len(OneItem))
NumberofRecords = LOF(1) / Len(OneItem)
FilePut(1, OneItem, NumberofRecords + 1)
NumberofRecords = NumberofRecords + 1
End Sub
Private Sub btnList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnList.Click
Dim Index As Integer
NumberofRecords = LOF(1) / Len(OneItem)
For Index = 1 To NumberofRecords
FileGet(1, OneItem, Index)
lstItems.Items.Add(String.Format(MyFormat, _
OneItem.Forename, OneItem.Surname, OneItem.Age))
'the code above displays items (records) in a list box
Next Index ' the file gets the next record in file and this process is repeated
' until end of records or no records are found
FileClose() 'the file Clients.dat is closed
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Filename = "Items.dat"
End Sub