VB程序开发中,写入文件的数据为啥行前有14个空格?

来源:百度知道 编辑:UC知道 时间:2024/09/25 07:20:59
Open fname For Input As #1
Open fname_1 For Output As #2
Open fname_100 For Output As #3
Print #2, , "户名|账号|日期|金额|"
Print #3, , "户名|账号|日期|金额|"
Do While Not EOF(1)
Line Input #1, nextline
Call str_trade(nextline, i_flag)
If i_flag > 0 Then
If i_flag = 2 Then
newline = newline & nextline
Else
newline = newline & nextline & "|"
End If
End If
'该处查看都没有空格
If i_flag = 3 Then
atm = CCur(nextline)
If atm > 10000 Then
'下面两行过滤空格和tab键
newline = Replace(newline, " ", "")
newline = Replace(newline, " ", "")
Print #2,, newline
If atm > 1000000 Then
Print #3,, newline
End If
End If
newline = &q

把 Print #2,, newline等改成Print #2, newline.
即去掉一个逗号.

每行前面都有14个空格,是因为你的print语句中多了一个逗号造成的。你改成以下就可以了:
Print #2, "户名|账号|日期|金额|"
Print #3, "户名|账号|日期|金额|"
Print #3, newline

dele ","