You appear to be working on the same assignment that another poster was
working on in the MSDN Visual Basic forum three years ago. After getting the
OP to post the project including the data file where it could be retrieved,
I discovered that the data file being used - rentals.txt - had an irregular
combination of CR and LF characters. Specifically it had:
(1) 0x0A characters only for end-of-line. This is typical of a file that
has been created on a Unix/Linux system.
(2) It had extra 0x0A characters at the end of the file: 0x0A 0x0A 0x0A
This indicates additional blank lines at the end of the file that should
not be there.
The OP had downloaded the text file from the project site, which explained
it's odd format. I suggested the OP recreate the file manually - using
WordPad preferably so as to better see where line breaks are occurring and
to be able to "see" the blank lines. After doing that the OP's original
problem disappeared.
Windows uses CRLF pairs to indicate EOL rather than just a solitary LF.
Some software can handle these different combinations automatically, others
require conversion.
The presence of extra blank lines at the end of the file caused the OP's
program to read those lines and try to process them as if they contained
data. This would cause a string format exception to be thrown.
You should try opening the data file in WordPad, and scroll to the bottom.
If it appears to have blank lines at the bottom, backspace to remove them
and save the file. Then try your program again. Note that this suggestion
is just to address one possible cause of the format exceptions. There
may well be other issues to address.