现在要做一个银行转帐的程序,要把我们公司的数据格式TXT转化成银行要求的,但现在银行要求要在开头加一个汇总,加上笔数和金额,请高人指点。出来的数据要求
RMB|4|160000  '4条数据
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX用下边代码跑出来的结果是
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
RMB|1|40000
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
RMB|2|80000
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
RMB|3|120000
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
RMB|4|160000代码如下,Print #4这两段就是要写进去的,如何改才能得到我要的格式: 
    Open StrSrcfile For Input As #1
    Do Until EOF(1)
    j = 0
    Line Input #1, strline
    strBank = MidX(strline, 12, 10)
    If MidX(strBank, 4, 3) = "ICB" Then
        If blexist = False Then
            blexist = True
            Open "2ICBDC" & CStr(Year(Date) * 10000 + Month(Date) * 100 + Day(Date)) & ".TXT" For Output As #4
            strfileexist(i) = "2ICBDC" & CStr(Year(Date) * 10000 + Month(Date) * 100 + Day(Date)) & ".TXT"
            i = i + 1
        Else
            Open "2ICBDC" & CStr(Year(Date) * 10000 + Month(Date) * 100 + Day(Date)) & ".TXT" For Append As #4
        End If
        x = 1
        For x = 1 To LenX(strline)
          strtemp = Mid(strline, x, 1)
          If strtemp <> vbTab Then
            If newfield = "Y" Then
              strdn(j) = strtemp
              newfield = " "
            Else
              strdn(j) = strdn(j) & strtemp
            End If
          Else
            j = j + 1
            newfield = "Y"
          End If
        Next x
    
    stricbc = "1002"
    strAccount = strdn(3)
    strnam = strdn(4)
    strPolNum = strdn(5)
    strduedate = strdn(20)
    strAmount = MidX(strdn(10), 3, 7) & MidX(strdn(10), 11, 2)
    'strAmount = Format(MidX(strdn(10), 2, 8)) & "." & MidX(strdn(10), 11, 2)
    Casecount = Casecount + 1
    Caseamount = Caseamount + Val(strAmount)    Print #4, "RMB|" & strduedate & "|2|1||440220976754026174|分公司|银行|||0000|" & LeftX(strAccount, 19) & "|" & Trim(strnam) & "|" & Format(strAmount) & "|||"    Print #4, "RMB|" & strduedate & "|1|" & Format(Caseamount) & "|" & Casecount & "|"  '这里就是我加的汇总
    Close #4
    End If
    Loop
    Close #1

解决方案 »

  1.   

    先存到string,最后在打印str=str & "RMB|" & strduedate & "|2|1||440220976754026174|分公司|银行|||0000|" & LeftX(strAccount, 19) & "|" & Trim(strnam) & "|" & Format(strAmount) & "|||"  & vbcrlf 
           End If 
        Loop str= "RMB|" & strduedate & "|1|" & Format(Caseamount) & "|" & Casecount & "|"  & vbcrlf & str
       Print #4, str
    Close #4     Close #1 
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
      

  2.   

        Print #4, "RMB|" & strduedate & "|1|" & Format(Caseamount) & "|" & Casecount & "|"  '这里就是我加的汇总 
        Close #4 
    移动到loop后面就可以了啊
      

  3.   

    先存到string,最后在打印 str=str & "RMB|" & strduedate & "|2|1||440220976754026174|分公司|银行|||0000|" & LeftX(strAccount, 19) & "|" & Trim(strnam) & "|" & Format(strAmount) & "|||"  & vbcrlf 
          End If 
        Loop str= "RMB|" & strduedate & "|1|" & Format(Caseamount) & "|" & Casecount & "|"  & vbcrlf & str 
      Print #4, str 
    Close #4     Close #1 
      
      

  4.   

    提示 Str 参数不可选是什么意思