ASP中查错之实例(尤其对初学者有帮助)!赖皮,昨天的错误原因

80酷酷网    80kuku.com

  初学|错误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 & "'
"
   ElseIf IsArray(Application.Contents(objItem)) Then
      Response.Write "Array: '" & objItem & "' contents are:
"
      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) & "
"
      Next
   Else
      Response.Write "Variable: '" & objItem & "' = " _
                     & Application.Contents(objItem) & "
"
   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 & "'
"
   End if
Next
%>

<!-- collect values to execute Application methods with -->
<FORM ACTION="<% = Request.ServerVariables("SCRIPT_NAME") %>" METHOD="POST">    ' 利用Request.ServerVariables("SCRIPT_NAME")将表单提交给自身

<P><DIV CLASS="subhead">Add a value to the Application Object</DIV>
<INPUT TYPE="SUBMIT" NAME="cmdAdd" VALUE="   ">
  Application("
<INPUT TYPE="TEXT" NAME="txtVarName" SIZE="15" VALUE="My_New_Value">
") = "
<INPUT TYPE="TEXT" NAME="txtVarValue" SIZE="20" VALUE="Testing, testing ...">
"<P>

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: