Contents 是由所有通过脚本命令添加到应用程序的项目组成的集合。可以使用 Contents 集合获取给定的应用程序作用域的项目的列表或指定一个特殊项目为操作对象。
Application.Contents(Key)
Application.Contents 集合包含了在应用程序一级未使用 <OBJECT> 标记声明的项目。其中包括用 Server.CreateObject 创建的对象和通过 Application 声明建立数值变量。例如,在下面的脚本中, MyVar 和 MyObj 将成为 Application.Contents 集合的成员:
<%
Application("MyVar") = "Hello"
Set Application("MyObj") = Server.CreateObject("MyComponent") %>
Application.Contents 集合支持 For...Each 和 For...Next 循环。下列两个脚本说明遍历 Application.Contents 集合的每种方法。
<%
For Each Key in Application.Contents
Response.Write ("Key")
Next Key
%>
<%
For i = 1 to Application.Contents.Count
Response.Write ("Key")
Next Key
%>
© 1997 by Microsoft Corporation. All rights reserved.