Appending data at the end of text file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cnehashah
    New Member
    • Mar 2007
    • 1

    Appending data at the end of text file

    hello
    I have started with visual basic and i want to know how can i append data into a text file at the end ,also fetching data from text file
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Use:

    Code:
    Open App.Path + "\YourFile.txt" For Append As filenum1
    as opposed to

    Code:
    Open App.Path + "\YourFile.txt" For Output As filenum1 ,
    Output erases the whole file or existing data and adds in new data.

    Hope this helps!

    Dököll

    Comment

    • ansumansahu
      New Member
      • Mar 2007
      • 149

      #3
      Originally posted by cnehashah
      hello
      I have started with visual basic and i want to know how can i append data into a text file at the end ,also fetching data from text file

      You can use this

      Public Sub FileOpen( _
      ByVal FileNumber As Integer, _
      ByVal FileName As String, _
      ByVal Mode As OpenMode, _
      Optional ByVal Access As OpenAccess = OpenAccess.Defa ult, _
      Optional ByVal Share As OpenShare = OpenShare.Defau lt, _
      Optional ByVal RecordLength As Integer = -1 _
      )

      Mode can be : Append, Binary, Input, Output, or Random

      So you need to use Append mode.

      thanks
      ansuman sahu

      Comment

      Working...