PDA

View Full Version : checking if a value exists in an array.. if so, imcerementing a total



numbenator
16 Aug 2005, 06:44 AM
Hi.
(problems updating the item in dictionary object)

I have 2 tables. portals and referals.
each portal has a referal against it (1 of upto 6) .
Referals in my dictionary will be keys and each key will maintain a count. (item)
I wish to count the number of different referals for each portal.

MY sub is below. I think i correctly create the keys but after i then get the portals to begin a check , I dont know how to update the item with + 1
The code i am missing is below if stat.Exists(portReferal)= true then :


sub getStats()

'get the referals
Set RS = Server.CreateObject("ADODB.Recordset")
set stat = Server.CreateObject("Scripting.Dictionary")
strSQL = "SELECT * FROM referals"
RS.Open strSQL, Conn
arrayCol=0
arrayRow=0
RS.MoveFirst

do while not RS.EOF
stat.add RS("referal"),0
RS.movenext
loop

set RS=nothing
Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM comments where portal="request.queryString("portal")
RS.Open strSQL, Conn
RS.MoveFirst

do while not RS.EOF
portReferal=RS("referal")
for i = 0 To stat.Count -1
if stat.Exists(portReferal)= true then
'how do I update the item here??????????????? end if
next
RS.movenext
loop

end sub