```vbnet
Const ForReading = 1 'Set the text opening mode to read
Const ForWriting = 2 'Set the text opening mode to write
Const ForAppending = 8 'Set the text opening mode to append
Const InFile = "a.txt" 'Set the text to open
Dim i, Sum
Dim StrLine, OutStr1, OutStr2
i = 1: Sum = 0
'On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject") 'Reference the FSO object, which is needed for reading and writing files
Set objFile = objFSO.OpenTextFile(InFile, ForReading) 'Open InFile in read mode
Do Until objFile.AtEndOfStream
StrLine = objFile.ReadLine 'Read a line
If Len(StrLine) Then 'If it's not an empty line
'MsgBox Mid(StrLine, Len(StrLine) - 58, 1) Test (commented out).
If Mid(StrLine, Len(StrLine) - 58, 1) = "1" Then 'Should the count from the end be correct?
OutStr1 = OutStr1 & StrLine & vbCrLf
Else
OutStr2 = OutStr2 & StrLine & vbCrLf
End If
End If
Loop
objFile.Close 'Close the file object
Set objFile = objFSO.OpenTextFile("a1.txt", ForWriting, True)
objFile.Write OutStr1
objFile.Close
Set objFile = objFSO.OpenTextFile("a2.txt", ForWriting, True)
objFile.Write OutStr2
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
[ Last edited by wangsky100 on 2010-10-2 at 20:43 ]
```
Const ForReading = 1 'Set the text opening mode to read
Const ForWriting = 2 'Set the text opening mode to write
Const ForAppending = 8 'Set the text opening mode to append
Const InFile = "a.txt" 'Set the text to open
Dim i, Sum
Dim StrLine, OutStr1, OutStr2
i = 1: Sum = 0
'On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject") 'Reference the FSO object, which is needed for reading and writing files
Set objFile = objFSO.OpenTextFile(InFile, ForReading) 'Open InFile in read mode
Do Until objFile.AtEndOfStream
StrLine = objFile.ReadLine 'Read a line
If Len(StrLine) Then 'If it's not an empty line
'MsgBox Mid(StrLine, Len(StrLine) - 58, 1) Test (commented out).
If Mid(StrLine, Len(StrLine) - 58, 1) = "1" Then 'Should the count from the end be correct?
OutStr1 = OutStr1 & StrLine & vbCrLf
Else
OutStr2 = OutStr2 & StrLine & vbCrLf
End If
End If
Loop
objFile.Close 'Close the file object
Set objFile = objFSO.OpenTextFile("a1.txt", ForWriting, True)
objFile.Write OutStr1
objFile.Close
Set objFile = objFSO.OpenTextFile("a2.txt", ForWriting, True)
objFile.Write OutStr2
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
[ Last edited by wangsky100 on 2010-10-2 at 20:43 ]
```

