[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

Delete all records in a text file except first line

From vb 6, how to delete all records in a txt file keeping only first line (column header or field names) intact.

thanks.
0
Mike Eghtebas
Asked:
Mike Eghtebas
2 Solutions
 
Jaime OlivaresCommented:
Hi eghtebas,
Have a look to this previous question:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20549308.html

Good luck,
Jaime.
0
 
_agj_Commented:
why not read in the first line, delete the file and write to it newly?

dim strBuf as string

open "fil1.txt" for input as #1
Line input #1, strBuf
close #1
Kill "fil1.txt"
open "fil1.txt" for output as #1
Print #1, strBuf
close #1
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Hi  _agj_,

Your solution is more suitble to use in my application.  I am testing it now.

Hi Jaime,

Thank you for the link.  I don't have complication (requiring the file has to exist and can't be deleted, etc.).  

Regards,

mike
0
 
vinnyd79Commented:
Just a note,you don't need to kill the file in agj's example because when you open it for output the file will be overwritten.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now