text file argent pls

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mktilu
    New Member
    • Apr 2007
    • 23

    text file argent pls

    Hi

    can any one help me to write a string in spefic position in text file from vb6.
    I want to search one string and write new one there
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by mktilu
    can any one help me to write a string in spefic position in text file from vb6.
    I want to search one string and write new one there
    I think the simplest way would be to Open the file in binary mode, Get the entire file into a String (see sample), use either Replace() function or Mid() function to replace the text, then Put the entire string back to the file. Note, the sample I quoted only shows how to read in the file, it will need a little modification to be able to write back to the file. But not much.

    There are probably plenty of other methods you could use.

    Comment

    • Mague
      New Member
      • May 2007
      • 137

      #3
      A even easier way is the code bellow


      Reads

      Imports System.IO
      Sub stuff
      Dim strline as string
      dim objstreamreader as streamreader

      objstreamreader = New streamreader("C :\source")
      strline = objstreamreader
      do while not strline is nothing
      msgbox(strline) ' Can use other way to write line
      strline = objstreamreader
      loop
      objstreamreader .close()


      Writes

      Imports system I.O
      sub stuff
      Objstreamwriter as streamwriter
      objstreamwriter = New Streamwriter("C :\source")
      objstreamwriter .writeline("Top line to write")
      objstreamwriter .writeline("Sec ond line to write")
      objstreamwriter .close()

      Hope this helps u if not please dont yell at me im only 13 and havnt had any programing experience (yew i start next year)

      Have Fun!
      Mague

      Comment

      Working...