Re: Quick one - array
- From: "Anthony Jones" <Ant@xxxxxxxxxxxxxxxx>
- Date: Wed, 13 Dec 2006 12:21:02 -0000
"Hilton" <get_chatting@xxxxxxxxxxx> wrote in message
news:uPF6whcHHHA.3668@xxxxxxxxxxxxxxxxxxxxxxx
Hi,1
I have an array I want to populate with the count of each unique item in a
particular field. i.e the array with pick up each unique item in the field
and set it's upper limit to the number of records it picks up for each
unique item
A 100
B 150
C 200
How do I do this without having hard code the size of each item eg for i =
to 100, etc
Assuming your not using a SQL compliant data source where GROUP BY and COUNT
would be the appropriate solution and if you're not too fussy about using
scrrun.dll then the Scripting.Dictionary object can help eg:-
Set oDict = New Scripting.Dictionary
oDict("A") = oDict("A") + 1
oDict("B") = oDict("B") + 1
oDict("A") = oDict("A") + 1
oDict("C") = oDict("C") + 1
oDict("A") = oDict("A") + 1
oDict("B") = oDict("B") + 1
oDict("A") = oDict("A") + 1
For Each key In oDict
listbox1.AddItem key & ": " & oDict(key)
Next
Generates:-
A: 4
B: 2
C: 1
Anthony.
.
- References:
- Quick one - array
- From: Hilton
- Quick one - array
- Prev by Date: RE: 800a01ad error while debugging VB6 DLL under IIS6.0 on Win2003SP1
- Next by Date: Sending SMS from VB using an SMS service provider
- Previous by thread: Quick one - array
- Next by thread: RE: 800a01ad error while debugging VB6 DLL under IIS6.0 on Win2003SP1
- Index(es):
Relevant Pages
|