Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Dictionary and Arrays

Status
Not open for further replies.

hblackorby

Programmer
Feb 13, 2001
164
US
Hi,
I pull a number of values out of a database and put them into a Dictionary object using .Exists() method to make sure that I only have a set up unique values. What I need to do is then write out all the keys. When I get the key array, it seems to work fine until I attempt to write something out. Then it acts like it's not an array any more.

(volts is my dictionary)
Response.Write &quot;<br>&quot; & volts.Count & &quot;<br>&quot;
keyarray = volts.Keys()
if isarray(keyarray) then
Response.Write lbound(keyarray) & &quot;-&quot; & ubound(keyarray) & &quot;<br>&quot;
for j = lbound(keyarray) to ubound(keyarray)
Response.Write j & &quot;: &quot;
Response.Write keyarray(j) & &quot;<BR>&quot;
next
else
Response.Write &quot;Keyarray is not an array.<Br>&quot;
end if
volts.RemoveAll
set volts = nothing

Output:
6
0-5
0: error '80020009'
Exception occurred.
/emcatalog/cr/motorguide2.asp, line 62
Where line 62 is where I try to write out keyarray(j).
&quot;exception occured&quot; is not useful at all.

Any help is greatly appreciated. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
I have received that error before, and it usually occurs when I try to go OVER the uBound of an array.

Just for kicks, I would be interested to see where the code bombs if you try to output
Code:
Response.Write keyarray(j + 1)
 
It bombs whenever I try to write keyarray(j) It behaves like an array until I try to write something out of it. If I try to write out keyarray(0) (or 1) it give me &quot;Object no longer valid&quot; and doesn't even give a line error number. This is very weird. However it doesn't fail the IsArray check, and it will write out the lbound() and ubound() values fine (see the output). Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
The only thing that I can see that even remotely resembles an error is where you call the .keys method.

In my documentation, it is called without the parentheses.

Though it seems like you would get the all-to-familiar &quot;Can't use parentheses when calling a sub&quot; error, I would try it, at least.

Other than that, I'm stumped. :-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top