• 0

[VB] Saving an array to a file


Question

Ok I have a little program I have to write for college and I am new to vb so I was wondering if anyone could help me out with this.

I have a product list which is stored in an array. I want to be able to save this array to a file and then retrieve it every time I load the program. Also when the program loads I want to be able to check to see if the file exists, if not load a default array which will be hard coded.

The code I have so far for saving the array is:

Open "data.bin" For Binary Access Write Lock Read Write As #1
Put #1, 1, StockItems
Close #1

I don't think that saves the whole array. Could anyone confirm that?

Something else I would like to be able to do is remove products from the array and re-index the array, I'm not sure what the function I would use to do that. Any help would be appreciated. o:)

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

try something like this...

Dim x As Integer

Open "data.bin" For Binary Access Write Lock Read Write As #1

For x = LBound(StockItems) to UBound(StockItems)
    Put #1, x, StockItems(x)
Next x

Close #1

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.