本帖最后由 czjt1234 于 2023-3-2 20:46 编辑
- Set fso = CreateObject("Scripting.FileSystemObject")
- set file = fso.OpenTextFile("a.txt")
-
- Do Until file.AtEndOfStream
- strLine = file.ReadLine
- If strLine <> "" Then
- ReDim PreServe br(n)
- strIn = strIn & "$" & strLine & " "
- br(n) = strIn
- n = n + 1
- End If
- Loop
-
- n = n - 1
- cr = Split(strIn)
- strIn = ""
- ReDim ar(n)
- For i = 0 To n
- j = cr(n - i)
- strIn = strIn & j & " "
- ar(i) = strIn
- Next
-
- 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
复制代码
|