回复 3楼 zxh48911805
代码我已修改了还是只能出来一点
Open "D:\原始资料\" & arr(1, 42) & "-CJ-" & myDate & ".txt" For Output As #1
Text1.Text = "D:\原始资料\CS-1-WY-" & VBA.Format(Now(), "yyyymmdd") & ".dat,输出完成"
Print #1, arr(1, 1) & " "
If arr(2, 2) < 0 Then
Print #1, arr(2, 1) & VBA.Format(arr(2, 2), "00000000") & " "
Else
Print #1, arr(2, 1) & "+" & VBA.Format(arr(2, 2), "00000000") & " "
End If
For b = 1 To C
If arr(b * 3, 2) < 0 Then
Print #1, arr(b * 3, 1) & VBA.Format(arr(b * 3, 2), "00000000") & " " & arr(b * 3, 3) & VBA.Format(arr(b * 3, 4), "00000000") & " "
Else
Print #1, arr(b * 3, 1) & "+" & VBA.Format(arr(b * 3, 2), "00000000") & " " & arr(b * 3, 3) & VBA.Format(arr(b * 3, 4), "00000000") & " "
End If
If arr(1 + b * 3, 2) < 0 Then
Print #1, arr(1 + b * 3, 1) & VBA.Format(arr(1 + b * 3, 2), "00000000") & " " & arr(1 + b * 3, 3) & VBA.Format(arr(1 + b * 3, 4), "00000000") & " "
Else
Print #1, arr(1 + b * 3, 1) & "+" & VBA.Format(arr(1 + b * 3, 2), "00000000") & " " & arr(1 + b * 3, 3) & VBA.Format(arr(1 + b * 3, 4), "00000000") & " "
End If
If arr(2 + b * 3, 2) < 0 Then
If arr(2 + b * 3, 6) < 0 Then
Print #1, arr(2 + b * 3, 1) & VBA.Format(arr(2 + b * 3, 2), "00000000") & " " & arr(2 + b * 3, 3) & VBA.Format(Left(arr(2 + b * 3, 4), 8), "00000000") & " " & arr(2 + b * 3, 5) & VBA.Format(arr(2 + b * 3, 6), "00000000") & " "
Else
Print #1, arr(2 + b * 3, 1) & VBA.Format(arr(2 + b * 3, 2), "00000000") & " " & arr(2 + b * 3, 3) & VBA.Format(Left(arr(2 + b * 3, 4), 8), "00000000") & " " & arr(2 + b * 3, 5) & "+" & VBA.Format(arr(2 + b * 3, 6), "00000000") & " "
End If
Else
If arr(2 + b * 3, 6) < 0 Then
Print #1, arr(2 + b * 3, 1) & "+" & VBA.Format(arr(2 + b * 3, 2), "00000000") & " " & arr(2 + b * 3, 3) & VBA.Format(Left(arr(2 + b * 3, 4), 8), "00000000") & " " & arr(2 + b * 3, 5) & VBA.Format(arr(2 + b * 3, 6), "00000000") & " "
Else
Print #1, arr(2 + b * 3, 1) & "+" & VBA.Format(arr(2 + b * 3, 2), "00000000") & " " & arr(2 + b * 3, 3) & VBA.Format(Left(arr(2 + b * 3, 4), 8), "00000000") & " " & arr(2 + b * 3, 5) & "+" & VBA.Format(arr(2 + b * 3, 6), "00000000") & " "
End If
End If
Next
Print #1, ""
Close #1
line1:
xlBook.Close False
'关闭工作簿,结束进程
Set xlBook = Nothing
oExcel.Quit
Set xlExcel = Nothing
End If
End Sub