justsomeguy Posted June 12, 2006 Share Posted June 12, 2006 I'm working with an ASP dictionary object, and I'm seeing some behavior that I can't explain. This is the code: set dictObj = CreateObject("Scripting.Dictionary")response.write("<!-- created dictionary -->"&vbcrlf)while (not passing.eof) if isnull(passing.fields.item("pass_score").value) or passing.fields.item("pass_score").value = "" then passingscore = 0 else passingscore = passing.fields.item("pass_score").value end if response.write("<!-- "&passingscore&" -->"&vbcrlf) dictObj.Add passing.fields.item("cid").value, passingscore response.write("<!-- "&passing.fields.item("cid").value&" -->"&vbcrlf) response.write("<!-- "&dictObj.Item(passing.fields.item("cid").value)&" -->"&vbcrlf) passing.movenext()wendpassing.close()dim cidscids = dictObj.Keys ' all of the cids in the groupnumOf = UBound(cids) ' number of scores to checkresponse.write("<!-- there are "&numOf&" keys -->"&vbcrlf) This is the output I'm getting: <!-- created dictionary --><!-- 85 --><!-- url02 --><!-- 85 --><!-- there are 0 keys --> The last line says that there are 0 keys in the dictionary, but I clearly add an item, with a key, and then immediately print it out again to verify that it is actually there (which it is). But then the Keys property is empty, or something else is going on.Can anyone see anything I'm missing? Link to comment Share on other sites More sharing options...
aspnetguy Posted June 19, 2006 Share Posted June 19, 2006 does declaring numOf make a difference? It doesn't appear to be declared.Or perhaps try this UBound(dictObj.Keys) I'm not too familiar witht he Dictionary object but I hope this helps a little.BTW, you don't get an errors do you? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 19, 2006 Author Share Posted June 19, 2006 No, I don't get any errors.If I can remember where I have that code, I'll go declare the variable and see if that makes a difference. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now