|
这是我网上找到的函数
运行 报错
问题在哪呢?
Function ClearSpaceLineA(PathFileName)
Rem 上面的方法可能会留下第一行、最后一行为空
Dim fso, fr, fw, frStr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fr = fso.OpenTextFile(PathFileName)
frStr = fr.ReadAll
fr.Close
Dim MyArray, i, j
j = 0
MyArray = Split(frStr, Chr(13) + Chr(10))
For i = 0 To UBound(MyArray)
If MyArray(i) <> "" Then
ReDim Preserve A(j)
A(j) = MyArray(i)
j = j + 1
End If
Next
frStr = Join(A, vbCrLf)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fw = fso.OpenTextFile(PathFileName, 2, True)
fw.Write frStr
fw.Close
Set fr = Nothing
Set fso = Nothing
End Function
|
|