PDA

View Full Version : processing 2 dictionaries at same time to calculate percentages.



numbenator
17 Aug 2005, 05:21 AM
Hi,
Im tring to calculate the percentage value of items in a dictionary against a total portalCount.
My sub below works to : response.write("percentages calclulated")
but beyond that I am getting a server error.
Could someone please eye over the code to see what done wrong. I am assuming it is related to referencing 2 dictionaries maybe.

this sub is called from another sub whereby the dictionary stat is defined so I havnt passed it to this sub. (when i do anyway it errors)


sub getPercents(portalCount)
set stat = Server.CreateObject("Scripting.Dictionary")
for i = 0 To stat.Count -1
perCent = (stat.item(i)/portalCount) * 100
perCentDictionary.Add elem,perCent
next
response.write("percentages calclulated")

For Each elem In perCentDictionary
response.write(elem)
response.write(",")
response.write(perCentDictionary(elem))
response.write("<br/>")
next
end sub