# Thread: how to count number of similar array values?

1. ## how to count number of similar array values?

i have a webtable which contains some codes like NG, NA, NX, NR etc... for the 1st to 30th of a month.

i need to capute this code from the webtable and count like how many NG are there or how many NA, NX or NR codes are there and get the result as:
NG count = 5
NA count = 7
NX count = 4......and so on.

if i capture this data in an array then how will i count the no. of times NX, NG, NR etc is repeated.

note: one will not be sure that the table will show NX, NG, NR or NA codes only..it can be any codes.

3. ## Re: how to count number of similar array values?

here is the code:
--------------------------------------------------------

a = array("NG","NA","NX","NR","NG","NA","NR","NG")
str = ""

For i =0 to ubound(a)
If instr(1,str,a(i)) Then
Else
str = str &amp; "," &amp;a(i)
End If
Next

msgbox str

res1 = split(str,",")

str2 = ""
For i=1 to ubound(res1)
c =0
For j = 0 to ubound(a)
If res1(i) = a(j) Then
c = c +1
End If
Next
str2 = str2 &amp; "," &amp; cstr(c)
Next

res2 = split(str2,",")

For i =1 to ubound(res1)
msgbox res1(i) &amp; " count = " &amp; res2(i)
Next

-------------------------------------------------------

4. ## Re: how to count number of similar array values?

Thanks Appy.. it worked..

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.