Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21271

Counting variations using two dimensional array

$
0
0
Hi

I need to count variations within a certain field from a text file which I read in.

Basically, file is read.
String is split based on the delimiter and read into an array
String(2) is the element which I need to count variations
String(1) is the number by which I need to increment the count by

Example

Data read in contains

1,apple
2,oranges
1,apple
1,pear
5,oranges

So I need to create a two dimensional array to hold the information

Somehow I need to end up with an array which has the following values

Apple,2
Oranges,7
Pear,1

How would be the best way to achieve this?

I saw an example somewhere of doing exactly this using 2d arrays a few months ago but can't find it now!

Kind regards

S

Viewing all articles
Browse latest Browse all 21271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>