Microsoft VBScript 运行时错误 错误 '800a0009' 下标越界
行19<%dimnumifrequest.form("inputtext")<>""thenstr=request.form("inputtext")dimx,allx=...
行19
<%
dim num
if request.form("inputtext")<> "" then
str=request.form("inputtext")
dim x,all
x=Split(str,",")
'计算平均数
for i=LBound(x) to UBound(x)
num = num/1
num = num+x(i)
next
all = UBound(x)+1
num = num / all
response.write num
response.write "</br>"
'计算方差
dim temp()
for i=LBound(x) to UBound(x)
temp(i) = 0
temp(i) = x(i) - num
temp(i) = temp(i) * temp(i)
next
dim endnum
for i=LBound(x) to UBound(x)
endnum= endnum / 1
endnum = endnum + temp(i)
next
endnum = endnum / all
%>
<%
end if
%>
方差计算器:
<form id="form1" name="form1" method="POST" action="index.asp">
<p>请将每个数据使用逗号(英文)分隔输入在文本框中:</br>
<label for="textarea"></label>
<textarea name="inputtext" id="inputtext" cols="100" rows="5"></textarea>
</p>
<p>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
</p>
</form> 展开
<%
dim num
if request.form("inputtext")<> "" then
str=request.form("inputtext")
dim x,all
x=Split(str,",")
'计算平均数
for i=LBound(x) to UBound(x)
num = num/1
num = num+x(i)
next
all = UBound(x)+1
num = num / all
response.write num
response.write "</br>"
'计算方差
dim temp()
for i=LBound(x) to UBound(x)
temp(i) = 0
temp(i) = x(i) - num
temp(i) = temp(i) * temp(i)
next
dim endnum
for i=LBound(x) to UBound(x)
endnum= endnum / 1
endnum = endnum + temp(i)
next
endnum = endnum / all
%>
<%
end if
%>
方差计算器:
<form id="form1" name="form1" method="POST" action="index.asp">
<p>请将每个数据使用逗号(英文)分隔输入在文本框中:</br>
<label for="textarea"></label>
<textarea name="inputtext" id="inputtext" cols="100" rows="5"></textarea>
</p>
<p>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
</p>
</form> 展开
2个回答
展开全部
dim temp() '这里定义了一个动态数组
for i=LBound(x) to UBound(x)
temp(i) = 0 '这里的动态数组即没有上标,也没有下标,不能直接应用的!
temp(i) = x(i) - num
temp(i) = temp(i) * temp(i)
next
在for i=LBound(x) to UBound(x)语句前声明动态数组的上标与下标,例如:
ReDim temp(LBound(x) , UBound(x)) 然后:
for i=LBound(x) to UBound(x)
temp(i) = 0
temp(i) = x(i) - num
temp(i) = temp(i) * temp(i)
next
这样才可以。
for i=LBound(x) to UBound(x)
temp(i) = 0 '这里的动态数组即没有上标,也没有下标,不能直接应用的!
temp(i) = x(i) - num
temp(i) = temp(i) * temp(i)
next
在for i=LBound(x) to UBound(x)语句前声明动态数组的上标与下标,例如:
ReDim temp(LBound(x) , UBound(x)) 然后:
for i=LBound(x) to UBound(x)
temp(i) = 0
temp(i) = x(i) - num
temp(i) = temp(i) * temp(i)
next
这样才可以。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询