WScript.Quit Main("Test.txt")Function Main(sFile)
Dim sTName, sLine, oFSO, fTmp, iComma
Main = 0
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTName = oFSO.GetTempName
Set fTmp = oFSO.CreateTextFile(sTName, True)
With oFSO.OpenTextFile(sFile, 1, False)
Do Until .AtEndOfStream
sLine = .ReadLine
iComma = FindThird(sLine, ",")
If iComma Then
fTmp.Write Left(sLine, iComma - 1)
fTmp.WriteLine Right(sLine, Len(sLine) - iComma)
Else
fTmp.WriteLine sLine
End If
Loop
End With
fTmp.Close
oFSO.DeleteFile sFile, True
oFSO.MoveFile sTName, sFile
End Function
Function FindThird(sIn, sComp) 'As Integer
On Error Resume Next
Dim i, start
FindThird = Null
start = 0
For i = 1 To 3
start = InStr(start + 1, sIn, sComp, 0)
Next
If Not Err Then _
FindThird = start
End Function