Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Edit a text file

 
Logged in as: Guest
arrSession:exec spGetSession 2,7,54057
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> Edit a text file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Edit a text file - 12/6/2007 12:03:50 AM   
  kpmsiva

 

Posts: 2
Score: 0
Joined: 12/5/2007
Status: offline
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
 
 
Post #: 1
 
 RE: Edit a text file - 12/6/2007 1:26:50 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
What have you written so far?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to kpmsiva)
 
 
Post #: 2
 
 RE: Edit a text file - 12/6/2007 2:11:39 PM   
  kpmsiva

 

Posts: 2
Score: 0
Joined: 12/5/2007
Status: offline
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???

(in reply to ebgreen)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> Edit a text file Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts