|
我写过,以下程序输出给工商银行的文本文件.
Private Sub 工行输出(ID As Integer, SQL As String, Err_str)
'SQL格式 帐号 姓名 合计
Dim db As Database
Dim rstTemp As Recordset
Dim strLine As String
Dim Hj As String
Dim NAME As String
Set db = CurrentDb
Set rstTemp = db.OpenRecordset(SQL)
Do Until rstTemp.EOF
With rstTemp.Fields
If Len(Trim(!帐号)) <> 19 Then
Err_str = Err_str & vbCrLf & !帐号 & " " & !姓名 & " " & !合计 & "帐号错误"
Else
strLine = Trim(!帐号) & " "
NAME = Trim(mID(!姓名, 2))
If Len(NAME) = 1 Then
NAME = " " & NAME & " "
End If
If Len(NAME) = 2 Then
NAME = NAME & " "
End If
strLine = strLine & Left(!姓名, 1) & NAME & " "
Hj = CStr(!合计 * 100)
Select Case Len(Hj)
Case 1: Hj = "00000000" & Hj
Case 2: Hj = "0000000" & Hj
Case 3: Hj = "000000" & Hj
Case 4: Hj = "00000" & Hj
Case 5: Hj = "0000" & Hj
Case 6: Hj = "000" & Hj
Case 7: Hj = "00" & Hj
Case 8: Hj = "0" & Hj
End Select
strLine = strLine & Hj
Print #ID, strLine
End If
rstTemp.MoveNext
End With
Loop
Set rstTemp = Nothing
Set db = Nothing
End Sub
|
|