我想将总投资扣减的细分显示为数组列表。 扣除额的总金额为-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.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>
答案 0 :(得分:0)
如果我们有可以执行的东西,那么调试会更容易,但只是猜测我认为你的问题就在这里:
<%total = total + SwitchList(i).SwitchOutDollarValue%>
<%total = total * -1%>
Total
是一个负值,我相信SwitchOutDollarValue是一个正值,所以以这种方式对它们进行组合并不会得到你想要的结果。
正如@SearchAndResQ所提到的,我会从<%total = total * -1%>
循环中移除for
并将其移至显示总数之前。