| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 411 人关注过本帖
标题:计算问题
只看楼主 加入收藏
kombel
Rank: 2
等 级:论坛游民
帖 子:69
专家分:48
注 册:2011-6-15
结帖率:92.31%
收藏
已结贴  问题点数:10 回复次数:5 
计算问题
图片附件: 游客没有浏览图片的权限,请 登录注册
怎么总额计算错误的
程序代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/connshop.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("cx") <> "") Then
  Recordset1__MMColParam = Request.QueryString("cx")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_connshop_STRING
Recordset1.Source = "SELECT * FROM pay WHERE author = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>
<html xmlns="http://www.>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body><table width="700" border="1" cellpadding="5" cellspacing="0" bordercolor="#E8E09F"  id="detailItem" align="center" >

 <tr>
  <td colspan="6" nowrap bgcolor="#F3EFCD" class="STYLE7 " align="center"><h1>出仓单</h1></td></tr>
  <tr>
  <td colspan="2" nowrap bgcolor="#F3EFCD" class="STYLE7 "><span class="STYLE7 "><strong>客户名称:</strong><strong><%=(Recordset1.Fields.Item("user").Value)%>
    <label></label>
  </strong></span></td>
  <td nowrap bgcolor="#F3EFCD" colspan="2" class="STYLE7 "><strong> 电话:<%=(Recordset1.Fields.Item("tel").Value)%></strong></td>
  <td nowrap bgcolor="#F3EFCD" colspan="2" class="STYLE7 "><strong>NO.
      <label></label>
      <%=(Recordset1.Fields.Item("NO").Value)%></strong></td>
  </tr>
  

 
  <tr>
    <td  nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>商品名称</strong></td>
    <td   nowrap bgcolor="#F3EFCD" class="td1 STYLE7" align="center"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
    <td  nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>单位</strong></td>
    <td  nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>数量</strong></td>
     <td   nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>单价</strong></td>
     <td   nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>金额</strong></td>
  </tr>
  <%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
    <tr >
      <td   nowrap bgcolor="#F3EFCD" ><%=(Recordset1.Fields.Item("name").Value)%></td>
      <td   nowrap bgcolor="#F3EFCD"><%=(Recordset1.Fields.Item("size").Value)%></td>
      <td   nowrap bgcolor="#F3EFCD"><%=(Recordset1.Fields.Item("unit").Value) %></td>
      <td  nowrap bgcolor="#F3EFCD"><%quantityw=(Recordset1.Fields.Item("quantity").Value)
       response.Write(quantityw)%></td>
      <td  nowrap bgcolor="#F3EFCD"><%price=(Recordset1.Fields.Item("pric").Value)
      sum=quantityw*price
       response.Write(price)%></td>
      <td nowrap bgcolor="#F3EFCD"><%response.write(sum)%></td>
    </tr>
    <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
<tr>
  <td colspan="7" nowrap bgcolor="#F3EFCD" class="STYLE7 " align="center">总额:
  <%dim i,sum2
  for i=1 to sum
  sum2=sum+i
  next
  response.Write(sum2)%>
  </td>
</tr>


</table>
</body></html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
2011-06-30 10:54
dzt0001
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1281
专家分:4998
注 册:2005-10-12
收藏
得分:10 
  for i=1 to sum
  sum2=sum+i
  next
用上面的代码能得到总金额吗?

你要汇总来,也应该在前面While...wend中写代码,sum2=sum2+sum

----我怎能在别人的苦难面前转过脸去----
2011-06-30 11:59
kombel
Rank: 2
等 级:论坛游民
帖 子:69
专家分:48
注 册:2011-6-15
收藏
得分:0 
要怎么加呢
2011-06-30 12:00
kombel
Rank: 2
等 级:论坛游民
帖 子:69
专家分:48
注 册:2011-6-15
收藏
得分:0 
回复 2楼 dzt0001
要怎么加啊  我加过一次不成功就删除了
2011-06-30 12:01
dzt0001
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1281
专家分:4998
注 册:2005-10-12
收藏
得分:0 
程序代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/connshop.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("cx") <> "") Then
  Recordset1__MMColParam = Request.QueryString("cx")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_connshop_STRING
Recordset1.Source = "SELECT * FROM pay WHERE author = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>
<html xmlns="http://www.>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body><table width="700" border="1" cellpadding="5" cellspacing="0" bordercolor="#E8E09F"  id="detailItem" align="center" >
<tr>
  <td colspan="6" nowrap bgcolor="#F3EFCD" class="STYLE7 " align="center"><h1>出仓单</h1></td></tr>
  <tr>
  <td colspan="2" nowrap bgcolor="#F3EFCD" class="STYLE7 "><span class="STYLE7 "><strong>客户名称:</strong><strong><%=(Recordset1.Fields.Item("user").Value)%>
    <label></label>
  </strong></span></td>
  <td nowrap bgcolor="#F3EFCD" colspan="2" class="STYLE7 "><strong> 电话:<%=(Recordset1.Fields.Item("tel").Value)%></strong></td>
  <td nowrap bgcolor="#F3EFCD" colspan="2" class="STYLE7 "><strong>NO.
      <label></label>
      <%=(Recordset1.Fields.Item("NO").Value)%></strong></td>
  </tr>
  

  <tr>
    <td  nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>商品名称</strong></td>
    <td   nowrap bgcolor="#F3EFCD" class="td1 STYLE7" align="center"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></td>
    <td  nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>单位</strong></td>
    <td  nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>数量</strong></td>
     <td   nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>单价</strong></td>
     <td   nowrap bgcolor="#F3EFCD" class="STYLE7 td1" align="center"><strong>金额</strong></td>
  </tr>
  <%

 sum2=0    '总金额初始值=0
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
    <tr >
      <td   nowrap bgcolor="#F3EFCD" ><%=(Recordset1.Fields.Item("name").Value)%></td>
      <td   nowrap bgcolor="#F3EFCD"><%=(Recordset1.Fields.Item("size").Value)%></td>
      <td   nowrap bgcolor="#F3EFCD"><%=(Recordset1.Fields.Item("unit").Value) %></td>
      <td  nowrap bgcolor="#F3EFCD"><%quantityw=(Recordset1.Fields.Item("quantity").Value)
       response.Write(quantityw)%></td>
      <td  nowrap bgcolor="#F3EFCD"><%price=(Recordset1.Fields.Item("pric").Value)
      sum=quantityw*price
      sum2=sum2+sum
       response.Write(price)%></td>
      <td nowrap bgcolor="#F3EFCD"><%response.write(sum)%></td>
    </tr>
    <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
<tr>
  <td colspan="7" nowrap bgcolor="#F3EFCD" class="STYLE7 " align="center">总额:
  <%=sum2%>
  </td>
</tr>


</table>
</body></html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
自己看哪里改了。

----我怎能在别人的苦难面前转过脸去----
2011-06-30 12:11
kombel
Rank: 2
等 级:论坛游民
帖 子:69
专家分:48
注 册:2011-6-15
收藏
得分:0 
回复 5楼 dzt0001
厉害 就那么简单就搞定了
2011-06-30 13:41
快速回复:计算问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.038988 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved