Hi,
I'm trying to write records from a file into a listbox on my form.
My file is "customers.dat" and currently has one customer in it.
I keep getting an error reading "Unable to read beyond the end of the stream" at the FileGet line I have indicated below.
My code is here:
Private Sub btnAllCustomers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAllCustomers.Click
Dim index As Integer
Dim OneCustomer As CustomerType
filename = "customers.dat"
lstbCustomers.Items.Clear()
FileOpen(1, filename, OpenMode.Random, , , Len(OneCustomer))
For index = 0 To NumberOfCustomers
FileGet(1, OneCustomer) 'retrieves record ERROR IS HERE
lstbCustomers.Items.Add(String.Format(OneCustomer.strCustomerID, OneCustomer.strTitle, OneCustomer.strFirstname, OneCustomer.strSurname, OneCustomer.strPhoneNumber, OneCustomer.strPostcode))
Next
FileClose()
End Sub
Any help would be appreciated. I am still a newbie to coding so please make replies easy to understand :)
I'm trying to write records from a file into a listbox on my form.
My file is "customers.dat" and currently has one customer in it.
I keep getting an error reading "Unable to read beyond the end of the stream" at the FileGet line I have indicated below.
My code is here:
Private Sub btnAllCustomers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAllCustomers.Click
Dim index As Integer
Dim OneCustomer As CustomerType
filename = "customers.dat"
lstbCustomers.Items.Clear()
FileOpen(1, filename, OpenMode.Random, , , Len(OneCustomer))
For index = 0 To NumberOfCustomers
FileGet(1, OneCustomer) 'retrieves record ERROR IS HERE
lstbCustomers.Items.Add(String.Format(OneCustomer.strCustomerID, OneCustomer.strTitle, OneCustomer.strFirstname, OneCustomer.strSurname, OneCustomer.strPhoneNumber, OneCustomer.strPostcode))
Next
FileClose()
End Sub
Any help would be appreciated. I am still a newbie to coding so please make replies easy to understand :)