- Set fso = CreateObject("Scripting.FileSystemObject")
- set file = fso.OpenTextFile("a.txt")
-
- Do Until file.AtEndOfStream
- strLine = file.ReadLine
- If strLine <> "" Then
- ReDim PreServe ar(n)
- strIn = strIn & "$" & strLine & " "
- ar(n) = strIn : n = n + 1
- End If
- Loop
-
- For i = CLng(UBound(ar)/2) to 0 step -1
- ar1 = Split(strIn,ar(i))
- If UBound(ar1) > 1 Then
- For j = 1 to UBound(ar1) - 1
- WriteToFile Split(ar1(j)),Split(ar(i))
- Next
- Exit For
- End If
- Next
-
- MsgBox "OK"
-
- Sub WriteToFile(ar2,ar3)
- If UBound(ar2) >= 1 Then
- strOut = Mid(ar2(UBound(ar2)-1),2)
- Else
- strOut = Mid(ar3(UBound(ar3)-1),2)
- End If
- fso.OpenTextFile("b.txt",8,True).WriteLine strOut
- End Sub
复制代码 保存为test.vbs,试试看,a.txt中不要包含空白字符的行。 |