日期:2013-01-05  浏览次数:20738 次

ASP中查错之实例
有这样一个程序,是对Application集合中的元素进行活动的添加与删除,程序如下:
<%@ LANGUAGE=VBSCRIPT %>
<HTML>
<HEAD>
<TITLE>The Application Object</TITLE>
<STYLE TYPE="text/css">
BODY {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
INPUT {font-family:Tahoma,Arial,sans-serif; font-size:9pt}
.heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt; font-weight:bold}
.subhead {font-family:Tahoma,Arial,sans-serif; font-size:12pt; font-weight:bold; padding-bottom:5px}
.cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<SPAN CLASS="heading">The ASP Application Object</SPAN><HR>
<!--------------------------------------------------------------------------->

<% 'look for a command sent from the FORM section buttons
If Len(Request.Form("cmdAdd")) Then                            ' 利用是否长度为0来判断
   strVarName = Request.Form("txtVarName")
   strVarValue = Request.Form("txtVarValue")
   Application.Lock
   Application(strVarName) = strVarValue                        ' 此处报错
   Application.Unlock
End If
If Len(Request.Form("cmdRemoveThis")) Then
   strToRemove = Request.Form("lstRemove")
   Application.Lock
   Application.Contents.Remove(strToRemove)
   Application.Unlock
End If
If Len(Request.Form("cmdRemoveAll")) Then
   Application.Lock
   Application.Contents.RemoveAll
   Application.Unlock
End If
%>

<P><DIV CLASS="subhead">The Application.Contents Collection</DIV>
<%
For Each objItem in Application.Contents
   If IsObject(Application.Contents(objItem)) Then
      Response.Write "Object reference: '" & objItem & "'<BR>"
   ElseIf IsArray(Application.Contents(objItem)) Then
      Response.Write "Array: '" & objItem & "' contents are:<BR>"
      varArray = Application.Contents(objItem)
      'note: the following only works with a one-dimensional array
      For intLoop = 0 To UBound(varArray)
         Response.Write "  Index(" & intLoop & ") = " & varArray(intLoop) & "<BR>"
      Next
   Else
      Response.Write "Variable: '" & objItem & "' = " _
                     & Application.Contents(objItem) & "<BR>"
   End If
Next
%>
<P><DIV CLASS="subhead">The Application.StaticObjects Collection</DIV>
<%
For Each objItem in Application.StaticObjects
   If IsObject(Application.StaticObjects(objItem)) Then
      Response.Write "<OBJECT> element: ID='" & objItem & "'<BR>"
   End if
Next
%>

<!-- collect values to execute Applicatio