Bob Schneider
asked on
Modify *.txt file in VB6
I have a text file named something like 192.168.1.159.txt It contains data like this:
1,101598,0,"15:34:43.416", 1,1
1,101571,0,"15:34:43.811", 1,1
1,101554,0,"15:34:43.609", 1,1
2,101554,0,"15:34:58.299", 2,2
3,101554,0,"15:34:59.225", 2,3
3,101554,0,"15:35:02.467", 2,3
3,101554,0,"15:35:06.144", 1,3
1,101554,0,"15:35:08.182", 1,1
1,101554,0,"15:35:13.465", 1,1
I want to remove one line from the file (it could have thousands of records). My plan is to create a temp.txt file, copy all the records except the one I don't want from the old file to the temp file, kill the old file, and rename the new file. Here is what I have so far:
If some one could help fill in the missing pieces, make corrections as needed, or offer a better suggestion that would be awesome!
Thanks in advance!!!
1,101598,0,"15:34:43.416",
1,101571,0,"15:34:43.811",
1,101554,0,"15:34:43.609",
2,101554,0,"15:34:58.299",
3,101554,0,"15:34:59.225",
3,101554,0,"15:35:02.467",
3,101554,0,"15:35:06.144",
1,101554,0,"15:35:08.182",
1,101554,0,"15:35:13.465",
I want to remove one line from the file (it could have thousands of records). My plan is to create a temp.txt file, copy all the records except the one I don't want from the old file to the temp file, kill the old file, and rename the new file. Here is what I have so far:
sBadRcd = lstFoundRcd.Text
Set fs = CreateObject("Scripting.FileSystemObject")
fname = sPath & "rfid\temp.txt"
Set ts = fs.CreateTextFile(fname)
iFileNum = FreeFile()
Open sRsltsFile For Input As iFileNum
sFileData = Input(LOF(iFileNum), #iFileNum)
Close iFileNum
LineArr = Split(sFileData, vbCrLf)
sFileData = vbNullString
'get all records except the one I want to delete
For i = 0 To UBound(LineArr) - 1
'if this record is not equal to sBadRcd then copy to temp.txt
Next i
Kill sRsltsFile
'rename new file
Set fs = Nothing
If some one could help fill in the missing pieces, make corrections as needed, or offer a better suggestion that would be awesome!
Thanks in advance!!!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Fabrice, what do you mean early and late binding?