How to create a matrix (x,y) type count

smohrmax
09-05-2009, 07:26 AM
Hi All,
I'm new to the VB6 thing. I am trying to convert and existing count program that was written in another code to VB6. Below is a sample of the current report format.

Product ID CompanyA CompanyB CompanyC Total
VB001 1 2 3 6
VB103 0 2 1 3
VB310 0 0 1 1

Total 1 4 5 10


This input datafile that is used is a csv (comma-delimited) file. The 2 field names I need to count is "Product ID" & "Company". When I parse the input record, "Product ID" is Field#5 and "Company" is Field#3. Any direction is greatly appreciated.

Thanks

mkaras
09-06-2009, 07:22 AM
Read each line of the input file as a string using in a loop. As each line is inputted break it up into its constituent parts using the Split() statement and specify "," as the delimiter to split on. After the split you will have an array of strings, one for each portion of the input string. Use the strings at the "Product ID" and "Company" locations to convert / compare / count the values of interest to you.

If the header record is actually in the .CSV file then remember to skip over it in the loop of reading the data. You may want to actually read the header record to locate the column names of interest to you so that in the case the data file format gets changed around your code would still work.

Lastly remember that a liberal amount of error checking is always a good idea to validate the input lines as they are read and split. As a minimum make sure you check for blank lines, lines with too few or too many fields, and that the data type in the fields of interest are correct.

mkaras

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum