kpmsiva
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 12/6/2007
-
Status: offline
|
Edit a text file
Thursday, December 06, 2007 1:03 AM
( permalink)
I have the Text file like this: "d:\test.txt" siva,1202 chand,1234 sivachand,4640 yogi,1245 I want to get the input from the user let, say (chand) then i will delete that chand line in the "d:\test.txt"..... The output of the "test.txt" should be siva,1202 sivachand,1234 yogi,1245 Any help can be Appreciated
|
|
|
|
ebgreen
-
Total Posts
:
8225
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: online
|
RE: Edit a text file
Thursday, December 06, 2007 2:26 AM
( permalink)
What have you written so far?
|
|
|
|
kpmsiva
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 12/6/2007
-
Status: offline
|
RE: Edit a text file
Thursday, December 06, 2007 3:11 PM
( permalink)
set objfso = CreateObject("Scripting.FileSystemObject") Set objread = objfso.opentextfile("d:\test.txt") set objwrite = objfso.CreateTextFile("d:\temp.txt",2) Do Until objread.AtEndofStream str = objread.ReadLine itemp = InStr(str,",") name = Left(str , itemp-1) number = Mid(str , itemp+1 ,Len(str)-1 ) msgbox name msgbox number if name = "chand" then ' Here Chand is the user input str = objread.ReadLine msgbox "Found" End if objwrite.WriteLine str loop Set objread = Nothing Set objwrite = Nothing Set objread = objfso.opentextfile("d:\temp.txt") strall = objread.ReadAll objread.close Set objwrite = objfso.CreateTextFile("d:\test.txt") objwrite.Write strall So far i finished using one temp text file for it... I want without using that temp file edit the "test.txt".... Is there any way to do it???
|
|
|
|