I'm parsing a tab delimited txt file. Each line in the file contains 3 fields: 1. nCells - which is constant and must be the same for each line 2. product index 3. counter (how many products were purchased)
I want to create an array that contains the product counter for each product index. The problem is that I fill this array while parsing the file, and I don't know the "nCells" property before entering the parsing loop.
Should I define an array of size 1 outside the parsing loop, and then, after parsing nCells, do something like:
If i = 1 Then ReDim array(1 to nCells)
Or is there a better way?
For example: For the following input file:
3 1 20
3 1 30
3 2 10
3 3 15
I want to create an array with 3 cells which contains 50 in cell#1 (20+30), 10 in cell#2 and 15 in cell#3. The problem is that I don't know in advance that I have 3 products and that my array should contain 3 cells. I only discover this while parsing the first row of the file. so I cannot declare a static array outside the loop, I have to declare a dynamic array inside the loop.
Thanks, Li