ASP 数组相加
如何让表内相加?需要输出总和:10我用<%price=rs("price")pprice=Split(price,",")Amout=0fori=0toUBound(pp...
如何让表内相加?需要输出总和:10
我用
<%price = rs("price")
pprice = Split(price,",")
Amout=0
for i=0 to UBound(pprice)
Amout=Amout+pprice(i)
Response.Write ""&pprice(i)&""
Next%>
这段语句,相加是3+4=7,而不是1+2+3+4=10! 展开
我用
<%price = rs("price")
pprice = Split(price,",")
Amout=0
for i=0 to UBound(pprice)
Amout=Amout+pprice(i)
Response.Write ""&pprice(i)&""
Next%>
这段语句,相加是3+4=7,而不是1+2+3+4=10! 展开
展开全部
<%price = rs("price")
pprice = Split(price,",")
Amout=0 '问题出在这里,如果你外层还有循环,比如执行rs.movenext后再回到这里,就把原来相加的值清零了,把这个放到外层循环以外就行了.
for i=0 to UBound(pprice)
Amout=Amout+pprice(i)
Response.Write ""&pprice(i)&""
Next%>
如
Amout=0 '在这里
Do Until rs.Eof
price = rs("price")
pprice = Split(price,",")
for i=0 to UBound(pprice)
Amout=Amout+pprice(i)
Next
rs.MoveNext
Loop
Response.Write Amout
pprice = Split(price,",")
Amout=0 '问题出在这里,如果你外层还有循环,比如执行rs.movenext后再回到这里,就把原来相加的值清零了,把这个放到外层循环以外就行了.
for i=0 to UBound(pprice)
Amout=Amout+pprice(i)
Response.Write ""&pprice(i)&""
Next%>
如
Amout=0 '在这里
Do Until rs.Eof
price = rs("price")
pprice = Split(price,",")
for i=0 to UBound(pprice)
Amout=Amout+pprice(i)
Next
rs.MoveNext
Loop
Response.Write Amout
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%price = rs("price")
pprice = Split(price,",")
Amout=0
for i=0 to UBound(pprice)
Amout=Amout+pprice(i)
Next
Response.Write ""&pprice(i)&""
%>
这样就可以了
pprice = Split(price,",")
Amout=0
for i=0 to UBound(pprice)
Amout=Amout+pprice(i)
Next
Response.Write ""&pprice(i)&""
%>
这样就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询