最近在系统地认真地学习ASP````看以下例子```` Code <% dim d,a,i set d=Server.CreateObject("Scripting.Dictionary") d.Add "n","Norway" d.Add "i","Italy" d.Add "s","Sweden"
Response.Write("
Key values:</p>") a=d.Keys for i=0 to d.Count-1 Response.Write(a(i)) Response.Write(" ") next
set d=nothing %> Output: Key values: n i s ================================================================== 为什么要用一个中间变量a让我困惑很久```在本地测试了一下```` Code <% dim d,a,i set d=Server.CreateObject("Scripting.Dictionary") d.Add "n","Norway" d.Add "i","Italy" d.Add "s","Sweden"
Response.Write("
Key values:</p>") for i=0 to d.Count-1 Response.Write(d.Keys(i)) Response.Write(" ") next
set d=nothing %> Output: Key values: Microsoft VBScript 运行时错误 '800a01c3' 对象不是一个集合: 'Keys' \wwwroot\test.asp, line 10 ==================================================================== 再做一个测试````` ===================================================================== Code <% dim d,a,i set d=Server.CreateObject("Scripting.Dictionary") d.Add "n","Norway" d.Add "i","Italy" d.Add "s","Sweden"
Response.Write("
Key values:</p>") a = d.Keys(i) for i=0 to d.Count-1 Response.Write(a) Response.Write(" ") next
set d=nothing %> Key values: Microsoft VBScript 运行时错误 '800a01c3' 对象不是一个集合: 'Keys' \wwwroot\test.asp, line 9 ================================================================ 问了下OnlyLonely大牛```他解决了我的困惑```` 原因很简单```Keys方法不支持带参数调用```` ASP没有重载的概念,不能像JavaScript那样直接操纵DOM```` 唉```计算机科班的人说话就是专业啊``` 因为一直都在自学```所以知识有很多漏洞是肯定的````没办法谁叫我才1X岁```` 继续加油吧````
|