I’m trying to figure out the best way to solve a problem in my program. Basically, I’ve got a listbox that holds book codes(1,2,3, etc). 1, 2, 3 would represent 3 different books. I have a text file that holds information such as:
Text file format:
bookCode, bookTitle, bookPrice, quantityofBooks
Text file dummy information:
1, Book One, 22, 5
2, Book Two, 10, 3
3, Book Three, 5, 15
I don’t always know how many lines there will be in this text file. What I’m trying to do is to split each individual line and put each line into some sort of array or list, and have the ability to access each individual item in those individual lists (items such as: Book One, Book Two, so that I can put these into a listbox) And, say for example someone clicks on “Book Two” in the list box, my label will change with the price for Book Two.
How can I put the bookTitle (Book One, Book Two, etc) into a listbox, and how can I split each line into separate lists and each individual items for that line into a list?
I’m not quite sure I’ve explained what I want as well as it could be explained. So I apologise if this has come across mind boggling.
declare this class
Then read from the file using this code: