Edit a text file

Author Message
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)
0
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
 
#1
    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)
    0
    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
     
    #2
      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)
      0
      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???
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • 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
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9