How to count matching text in specific array items in Visual Basic 2010

Associate
Joined
31 Dec 2002
Posts
458
Hi,

Is there a way to count the number of times for example the word "Yes" appears in an array, where you are only checking specific items in the array?

I can do a for loop which works, but this would only count the total number of occurrences in the array. My array has 24 items. i.e.

for i = 0 to 23
if array(i) = "Yes" then
total += 1
end if
next

what I am trying to do though is only check for example array items 1, 3, 6, 9 and 10 to see if they contain the text "Yes" and then assign the total to the variable total.

The reason for this is because I have a list of questions and have three categories of answers. Each category counts 'Yes' answers to specific questions i.e. category one applies if 1,4,6,7 answer 'Yes', category two applies if 8,10,11 answer 'Yes' and so on.

Thanks in advance. I have spent hours racking my brain over this!!!!!
 
Associate
OP
Joined
31 Dec 2002
Posts
458
thanks everyone. I sorted it in the end using a two dimensional array, and cycled through one set of data in a for loop and nested three if statements in the loop to run through each row of the array. A real head scratcher:) for me anyway, I will try out your solutions as well, as I want to learn more. Cheers.
 
Back
Top Bottom