line input #1 ,MyData if MyData<>"" then print #2, MyData endif
line input #1 ,MyData if trim(MyData)<>"" then print #2, MyData endif
replace(MyData,vbCrlf,"") replace(MyData," ","")
Tirm是VB专门为取出空格而生的:)
不关 Trim 什么事。楼主是要去掉文件尾的空行。Dim strTmp As StringOpen App.Path & "\a.txt" For Input As #1 Open App.Path & "\b.txt" For Output As #2Do Until EOF(1) Line Input #1, strTmp If strTmp > "" Then Print #2, strTmp LoopClose #2 Close #1
又或者,取出a.txt的内容到一数组里的时候,判断如果有空格就不加到list里面,没有空格的就加到list里面 Dim fp As Integer fp = FreeFile()
Open "a.txt" For Input As fp
While Not EOF(fp) Dim buffer As String Line Input #fp, buffer
If Trim(buffer) <> "" Then Call List1.Add(buffer) End If Wend
strReturn倒没用过,问一下, "str",是代表我取出来的数组吗?
if MyData<>"" then
print #2, MyData
endif
if trim(MyData)<>"" then
print #2, MyData
endif
replace(MyData," ","")
不关 Trim 什么事。楼主是要去掉文件尾的空行。Dim strTmp As StringOpen App.Path & "\a.txt" For Input As #1
Open App.Path & "\b.txt" For Output As #2Do Until EOF(1)
Line Input #1, strTmp
If strTmp > "" Then Print #2, strTmp
LoopClose #2
Close #1
fp = FreeFile()
Open "a.txt" For Input As fp
While Not EOF(fp)
Dim buffer As String
Line Input #fp, buffer
If Trim(buffer) <> "" Then
Call List1.Add(buffer)
End If
Wend
Close fp