Asp classic 演绎列表-ASP数组
我想以数组列表的形式显示总投资扣除额的明细。扣减的总金额为$-20.24,我的列表明细总和不等于该金额。我不太确定我哪里弄错了。请检查我的代码并提供反馈。请参阅下面返回的总值:Asp classic 演绎列表-ASP数组,asp-classic,Asp Classic,我想以数组列表的形式显示总投资扣除额的明细。扣减的总金额为$-20.24,我的列表明细总和不等于该金额。我不太确定我哪里弄错了。请检查我的代码并提供反馈。请参阅下面返回的总值: Date Units Unit price Value 30/04/2018 -4.203 $ 1.99143 $ -8.37 30/04/2018 -0.366 $ 1.99454 $ -0.73 30/04/2018 -1.576 $ 3.54
Date Units Unit price Value
30/04/2018 -4.203 $ 1.99143 $ -8.37
30/04/2018 -0.366 $ 1.99454 $ -0.73
30/04/2018 -1.576 $ 3.54061 $ -5.58
30/04/2018 -0.138 $ 3.55072 $ -0.49
30/04/2018 -1.871 $ 2.49065 $ -4.66
30/04/2018 -0.164 $ 2.50000 $ -0.41
Total amount $ 16.98
<%
Dim objMemberClient, SwitchList
set objMemberClient = Server.createObject("MemberServiceProxy")
SwitchList= objMemberClient.GetInvestmentTransactionObjList(session("MemberId"),session("FundCode"), request.Querystring("date"), request.Querystring("date"), request.Querystring("description"))
%>
<h1>Investments</h1>
<div class="table-responsive">
<%if request.Querystring("description") = "Deduction" then %>
<TABLE class="table">
<%for i = LBound(SwitchList) to UBound(SwitchList)%>
<%if SwitchList(i).DeductionCode = getDesc(request.Querystring("subtype")) then%>
<tr>
<%if SwitchList(i).DeductionSign = true then%>
<td class="table_Header" width="200px">Investment sold</td>
<%exit for%>
<%end if%>
<%end if%>
<%Next%>
<td class="table_Header" width="125px">Date</td>
<td class="table_Header" width="125px">Units</td>
<td class="table_Header" width="125px">Unit price</td>
<td class="table_Header" width="125px">Value</td>
</tr>
<%for i = LBound(SwitchList) to UBound(SwitchList)%>
<%if SwitchList(i).DeductionCode = getDesc(request.Querystring("subtype")) then%>
<tr>
<td valign="top" class="border_Bottom"> <%=SwitchList(i).InvestmentOption.Name%></td>
<td valign="top" class="border_Bottom"><%=SwitchList(i).InvestmentDate%></td>
<td valign="top" class="border_Bottom"> <%=SwitchList(i).NumberUnits%></td>
<%if SwitchList(i).DeductionSign = true then %>
<%total = total + SwitchList(i).SwitchOutDollarValue%>
<%total = total * -1%>
<td valign="top" class="border_Bottom">$ <%=FormatNumber(SwitchList(i).SwitchOutDollarValue/Replace(SwitchList(i).NumberUnits,"-",""),5)%></td>
<td valign="top" class="border_Bottom">$ -<%=FormatNumber(SwitchList(i).SwitchOutDollarValue,2)%></td>
<%end if%>
</TABLE>
日期单位单价值
30/04/2018 -4.203 $ 1.99143 $ -8.37
30/04/2018 -0.366 $ 1.99454 $ -0.73
30/04/2018 -1.576 $ 3.54061 $ -5.58
30/04/2018 -0.138 $ 3.55072 $ -0.49
30/04/2018 -1.871 $ 2.49065 $ -4.66
30/04/2018 -0.164 $ 2.50000 $ -0.41
总额16.98美元
投资
出售的投资
日期
单位
单价
价值
$
$ -
如果我们有一些可以执行的东西,那么调试就容易多了,但我猜你的问题就在这里:
<%total = total + SwitchList(i).SwitchOutDollarValue%>
<%total = total * -1%>
Total
是负值,SwitchOutDollarValue我认为是正值,因此以这种方式组合它们不会得到您想要的结果
正如@SearchAndResQ提到的,我将从
for
循环中删除
,并将其移动到显示总数之前。如果您注释掉total=total*-1
,会发生什么?@SearchAndResQ回避到:8.37-0.73+5.58-0.49+4.66-0.41=16.98