程序出错,显示器提示为:
错误类型:
Microsoft VBScript 运行时错误 (0x800A0006)
溢出
poll_bar.asp, 第 44 行
-----这是什么问题啊?敬请指点,感谢!感谢!
*********************************************************************************************
<%
'定义用于从给定文件(只)读取票数的函数:
Function ReadCount(CFile)
Dim objFSO,objTS
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
Set objTS=objFSO.OpenTextFile(Server.MapPath(CFile),1,True) '1,为只读
If Not objTS.AtEndOfStream Then
ReadCount=CLng(objTS.ReadLine)
Else
ReadCount=0
End If
objTS.Close
Set objFSO= Nothing
End Function
'定义用于将累计票数(只)写入指定文件的sub过程:
Sub WriteCount(CFile,Count)
Dim objFSO,objTS
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
Set objTS=objFSO.OpenTextFile(Server.MapPath(CFile),2,True) '2,为只写
objTS.WriteLine(Count)
objTS.Close
Set objFSO= Nothing
End Sub
%>
<%
Dim Vote,London1,Paris1,Sanfran1,Repeat,Total
Dim PLondon,PParis,PSanfran
Dim WLondon,WParis,WSanfran
Application.Lock()
'获取浏览者所投票的城市:
Vote=Request("Vote")
'从相应文件分别读取各城市已获得的票数
London1=ReadCount("London.txt")
Paris1=ReadCount("Paris.txt")
Sanfran1=ReadCount("Sanfran.txt")
'计算投票总数,并分别计算各城市得票的百分比:
Total=London1+Paris1+Sanfran1
PLondon=London1/Total
PParis=Paris1/Total
PSanfran=Sanfran1/Total
'根据各城市的得票百分比分别计算横条图的宽度:
WLondon=300*PLondon
WParis=300*PParis
WSanfran=300*PSanfran
'限制重复投票
If (vote<>Empty)And(Session("Repeat")=London or Paris or Sanfran) Then
Response.Write("您已经投过票,不能重复投票!")
Response.End
Else
' 判断当前得票的城市,并为其票数加1后写入对应文件:
If Vote="London" Then
London1=London1+1
WriteCount"London.txt",London1
Session("Repeat")=London
ElseIf Vote="Paris" Then
Paris1=Paris1+1
WriteCount"Paris.txt",Paris1
Session("Repeat")=Paris
ElseIf Vote="Sanfran" Then
Sanfran1=Sanfran1+1
WriteCount"Sanfran.txt",Sanfran1
Session("Repeat")=Sanfran
End If
End If
Application.UnLock()
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>魅力城市网上投票</title>
</head>
<body><center>
魅力城市网上投票<p>
目前共计收到选票<%=Total%>张.最近投票结果更新时间:<%=now%></p>
<table width="500">
<tr>
<td width="105" rowspan="2"><a href="poll_bar.asp?Vote=London"><img src="../../img/London.jpg" width="102" height="104"></td>
<td width="45" rowspan="2"> </td>
<td height="50" valign="bottom">伦敦得票:<%=London1%></td>
</tr>
<tr>
<td valign="middle"><img src="../../img/bar2.gif" width=<%=WLondon%>height="20">
<%=FormatPercent(PLondon)%></td>
</tr>
<tr>
<td width="105" rowspan="2"><a href="poll_bar.asp?Vote=Paris"><img src="../../img/Paris.jpg" width="101" height="104"></td>
<td width="45" rowspan="2"> </td>
<td height="50" valign="bottom">巴黎得票:<%=Paris1%></td>
</tr>
<tr>
<td valign="middle"><img src="../../img/bar2.gif" width=<%=WParis%>height="20">
<%=FormatPercent(PParis)%></td>
</tr>
<tr>
<td width="105" rowspan="2"><a href="poll_bar.asp?Vote=Sanfran"><img src="../../img/Sanfran.jpg" width="104" height="93"></td>
<td width="45" rowspan="2"> </td>
<td height="50" valign="bottom">旧金山得票:<%=Sanfran1%></td>
</tr>
<tr>
<td valign="middle"><img src="../../img/bar2.gif" width=<%=WSanfran%>height="20">
<%=FormatPercent(PSanfra)%></td>
</tr>
</table>
</center></body>
</html>