Hello,

I'm Rather new to coding, and It seems like I skipped some of the basics, and jumped in the deep end.

I'm having a couple of problems, as I have an ordinary text file called "Orders", and this file stores Orders, placed by users of my program.

The Users write to the Orders.txt file, 5 lines per Order, For Example :

Item Name
Item Quantity
UserName (Of user)
House Number (Of user)
Post Code (Of user)

i.e. (Three Orders Bellow)

PlayStation
2
Tobyjug2222
4
CH75LW
ToyCar
6
Tobyjug1111
5
CH64LW
Holiday
1
TobyJug3333
55
CH14JD

I want to be able to read this file, and store the data in Records, and having a form with a Previous/ Next button, displaying these orders.

Also on that form, a Delete button which will delete the order from the file when it has been processed.

Thanks a lot, Toby.

Recommended Answers

All 4 Replies

You will need a class with all of these fields defined.
Like your last project where you used a KeyValuePair, you will need to create a class.
Each field of the "record" will be populated by a row in the file.
When you've collected 5 rows, add that record to a master.

The master can be a List or Array or Dictionary of Orders

I suggest that you change the file format so that all info for an order is on the same line. Pick a character like "|" to separate the fields. Each line can be parsed into separate fields by

Dim fields() As String = line.Split("|")

It makes the file I/O much easier.

Thanks for your responses, although:

@thines01, I'm not exactly sure how to do that, I sent you what I interpreted to a private message.

@Reverend Jim, I tried to do this, although the command "Line" is supposedly not supported any more (what my VB told me) ;)

perhaps the code would have been clearer if I had included

dim line as string = "PlayStation|2|Tobyjug2222|4|CH75LW"

then the code

Dim fields() As String = line.Split("|")

would result in fields as an array of 5 elements where

fields(0) = "PlayStation"
fields(1) = "2"
fields(2) = "Tobyjug2222"
fields(3) = "4"
fields(4) = "CH75LW"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.