我有一个交易数据,需要总结金额,只将金额与日期范围相加。
JJ|
是每个记录和KD |的Delimeter是交易数据。
这是数据
JJ| | KD|15/08/16| |CASH |100.00| | KD| | | | | | KD|01/09/16|30/09/17|PACKAGE |35.00 |AAAA| KD| | |ONE | | | KD|01/09/16|30/09/17|PACKAGE |35.00 | | KD| | |ONE | | | KD|01/09/16|30/09/17|PACKAGE |35.00 | | KD| | |ONE | | | KD| | | | | | KD|15/08/16| |CASH |500.00| | KD| | | | | | KD|01/09/16|30/09/17|BREADER |25.00 |BBBB| KD| | |WWW | | | KD|01/09/16|30/09/17|BREADER |25.00 | | KD| | |WWW | | | KD|01/09/16|30/09/17|BREADER |25.00 | | KD| | |WWW | | | KD| | | | | | JJ| | KD|15/08/16| |CASH |110.00| | KD| | | | | | KD|01/09/16|30/09/17|ALIENWARE |35.00 |CCCC| KD| | |PPP | | | KD|01/09/16|30/09/17|ALIENWARE |35.00 | | KD| | |PPP | | | KD| | | | | | KD|15/08/16| |CREDIT |210.00| | KD| | | | | | KD|01/09/16|30/09/17|PACKAGE |25.00 |ABAB| KD| | |ONE | | | KD|01/09/16|30/09/17|PACKAGE |25.00 | | KD| | |ONE | | | KD| | | | | |
以下是需要调整的代码
Dim DelimeterAnnual
While Not line Is Nothing
Delimeter = line.Split("|")
If Delimeter(0) = "JJ" Then
fout.WriteLine(line)
ElseIf Delimeter(0) = "KD" Then
If Trim(Mid(Delimeter(2), 6, 3)) = "/17" Then
If Trim(Delimeter(4)) = "" Then
Else
nAnnualBill += CDec(Delimeter(4))
DelimeterAnnual = line.Split("|")
fout.WriteLine(DelimeterAnnual(0) & "|" & DelimeterAnnual(1) & "|" & DelimeterAnnual(2) & "|" & DelimeterAnnual(3) _
& "|" & nAnnualBill & "|" & DelimeterAnnual(5))
End If
End If
Else
fout.WriteLine(line)
End If
line = fh.ReadLine
End While
我希望实现的输出:
JJ| | KD|15/08/16| |CASH |100.00| | KD| | | | | | KD|01/09/16|30/09/17|PACKAGE |105.00|AAAA| KD| | |ONE | | | KD| | | | | | KD|15/08/16| |CASH |500.00| | KD| | | | | | KD|01/09/16|30/09/17|BREADER |75.00 |BBBB| KD| | |WWW | | | KD| | | | | | JJ| | KD|15/08/16| |CASH |110.00| | KD| | | | | | KD|01/09/16|30/09/17|ALIENWARE |70.00 |CCCC| KD| | |PPP | | | KD| | | | | | KD|15/08/16| |CASH |210.00| | KD| | | | | | KD|01/09/16|30/09/17|PACKAGE |50.00 |ABAB| KD| | |ONE | | | KD| | | | | |